session lifetime issues

From: Date: Mon, 24 Sep 2001 15:19:53 +0000
Subject: session lifetime issues
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-151@lists.php.net to get a copy of this message
I'm trying to implement a "save login info" choice, whereby, if the user checks the box, the session information will be maintained across multiple uses (usually, the session will expire upon closing the browser)... I'm using the session_set_cookie_params() to modify the session lifetime, but it doesn't seem to work. I read on another post saying that there was a bug in PHP4 where you could only control the session lifetime from the php.ini file, but that was posted 1 year ago... Anyway, here's my code... If you can help, I'd appreciate it. :) Thanks. <?php ob_start(); include("pmlib.php"); // just a custom php library include("classes.php"); // all my PHP classes if ( isset($username) ) { // login form field name if (! $userid = authenticate($username, $password) ) { // custom authentication method ob_end_flush(); echo start_html("Login Error"); echo "Login Error... you lose."; echo end_html(); exit; } else { $u = new User($userid); $logged_in_user_id = $userid; $logged_in_user_role = $u->role; if ( session_is_registered("logged_in_user_id") ) { session_destroy(); } session_register("logged_in_user_id", "logged_in_user_role"); // this doesn't work... don't know why... if ( $noexpire ) { // noexpire is the checkbox they check to save the session info.... session_set_cookie_params($lifetime = 10); } loadURL("StartPage"); // a redirect method... ob_end_flush(); exit; } } else { ob_end_flush(); echo start_html("Login Page"); echo start_form('login'); ?> // login form... When I check the results WITH session_get_cookie_params(), the lifetime parameter has not been changed... From what I can tell from the docs, the lifetime parameter is only an integer... I assume that's the number of says or seconds... When creating a non-session cookie, (setcookie(), I think) the expire parameter takes a time() value... Either way, the value for lifetime with session_set_cookie_params() never changes... HELP!

« previous php.gtk.general (#151) next »