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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.