Jump to content

[SOLVED] session.cookie_lifetime


jaymc

Recommended Posts

my php.ini file specifies that a session cookie dies when the browser is closed, therefor is set to 0

 

Im using ini_set to manipulate this setting however cant seem to get it working

 

I've written some test code but the session cookie is dying when the window is closed. here is the code

 

if ($_GET[a] == "start") {

ini_set('session.gc_maxlifetime', time() + 30);

ini_set('session.cookie_lifetime', time() + 30);

 

session_start();

$_SESSION['beans'] = "elolad";

echo "Loaded Session";

}

 

else if ($_GET[a] == "now") {

ini_set('session.gc_maxlifetime', time() + 30);

ini_set('session.cookie_lifetime', time() + 30);

session_start();

echo "session = ".$_SESSION['beans'];

}

 

Strangely, if i set the value to this

ini_set('session.cookie_lifetime', 30);

 

The session cookie does not die when I close the browser window, however, it does not die after 30 seconds either

 

Am I doing something wrong? I dont want to alter anything in myphp.ini file, I want to make this bespoke to a website therefor want to use ini_set

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/68602-solved-sessioncookie_lifetime/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.