note 13864 added to function.session-start.php
| From: | emeraldmedia at sunvalley dot net | Date: | Fri, 06 Jul 2001 23:07:56 +0000 |
| Subject: | note 13864 added to function.session-start.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15053@lists.php.net to get a copy of this message | ||
The following works great in IE but in Netscape it is not sending any of the variables to the next
page. So the person comes back !$authenticated and gets redirected back to the login page.
any tips would be great. i have been killing myself over this. im ready to throw myself out the
window.
// page one - login
<?php
session_start();
$current_page = str_replace('/', "", $HTTP_SERVER_VARS["PHP_SELF"]);
session_register("customer_id");
// checks mysql here
// comes back ok then ..
session_register("authenticated");
session_register("authenticated_expire");
$authenticated = 1;
$authenticated_expire = time() + (60 * 15); # set login timeout to 15 minutes from now
header("Location: page2.php");
// on page2.php //
<?php
session_start();
# register session_variables
session_register("authenticated");
session_register("authenticated_expire");
session_register("authenticated_error");
# first, see if they have been authenticated; if not, redirect to login
if ( !$authenticated ) {
$authenticated_error = "login_required";
header("Location: login.htm");
}
# ok, they've been authenticated -- now check idle time
if ( time() > $authenticated_expire ) {
# they've been idle more than 60 minutes, make them login again
$authenticated = 0;
$authenticated_error = "timeout";
header("Location: login.htm");
}
else {
# update idle timer and reset any authentication error message
$authenticated_expire = time() + (60 * 300);
$authenticated_error = "";
if ( $debug ) { echo "<STRONG>AUTHENTICATED: time " . time() . " expiration
" . $authenticated_expire . "<BR>"; }
}
?>
ps. good thing i live on the ground floor ;)
http://www.php.net/manual/en/function.session-start.php