Tags
Asked 2 years ago
13 Jul 2021
Views 189
Domenic

Domenic posted

Can we increase session time in PHP ?

Can we increase session time in PHP ?
eclipse-learner

eclipse-learner
answered May 5 '23 00:00

this are steps to increase the session time:
Open your PHP script and add the following code at the beginning of the script, before any output is sent to the browser:

// Set the session cookie lifetime to 1 hour (in seconds)
ini_set('session.cookie_lifetime', 3600);

// Set the session garbage collection time to 2 hours (in seconds)
ini_set('session.gc_maxlifetime', 7200);


This will set the session cookie lifetime to 1 hour and the session garbage collection time to 2 hours.

Save the PHP script and upload it to your web server.

Note that the session cookie lifetime and the session garbage collection time can also be set in the php.ini configuration file. If you have access to the php.ini file, you can modify the session.cookie_lifetime and session.gc_maxlifetime values directly in the file.
Post Answer