I have been at this for a day now, but nothing seems to be working. What I want to do: change the expiry time of the session cookie PHPSESSID, when a particular checkbox is checked , how do I do this ? I have tried:
ini_set()
session_set_cookie_params()
setcookie()
but nothing works . Can someone please please help me here ?
Thanks
To specify the session lifetime, server side, either apply the following command
ini_set('session.gc_maxlifetime', 30*60); // expires in 30 minutes
or set it in your php.ini
file.
To set the session cookie lifetime, client side, either let it as it is (0, will die when the browser is closed), or
ini_set('session.cookie_lifetime', 30*60); // 30 minutes
or in the php.ini
.
If you choose to use ini_set()
, be sure to place the commands before session_start()
is called.
Note that the ini_set
function sets configuration option(s) during the script execution time only.
Regarding the checkbox and having a dynamic setting of the session lifetime, you could
(each script will have to ini_set()
once before session_start()
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With