Re: session lifetime issues
| From: | Andrei Zmievski | Date: | Mon, 24 Sep 2001 15:24:25 +0000 |
| Subject: | Re: session lifetime issues | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-152@lists.php.net to get a copy of this message | ||
Please use php-general list for this kind of questions. This list is
about PHP-GTK.
On Mon, 24 Sep 2001, Ryan Huff wrote:
> 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!
-Andrei
* Software never has bugs. It just develops random features. *