Yes, you can change the session cookie timeout in your php.ini
file by updating two main directives:
🔧 Step-by-step Instructions
-
Locate your
php.ini
file:-
On most systems, it's in
/etc/php/[version]/apache2/php.ini
or/etc/php.ini
. -
Run
php --ini
in the terminal to find the correct file if you're unsure.
-
-
Open
php.ini
in a text editor:(Replace the path with the actual one from your system if different.)
-
Edit the session timeout settings:
Add or modify the following lines:
-
session.gc_maxlifetime
: This is the number of seconds after which data will be seen as 'garbage' and cleaned up by PHP's garbage collection. -
session.cookie_lifetime
: This sets how long the cookie should live on the client side (in seconds). If set to0
, the cookie expires when the browser closes.
Example:
3600
seconds = 1 hour. -
-
Save and close the file.
-
Restart your web server:
-
For Apache:
-
For Nginx with PHP-FPM:
-
Â
Tip for Application-Level Override
If you don't have access to php.ini
, you can add this to your script:
Â