Something is wrong with my sessions..
| From: | Chad Day | Date: | Fri, 19 Jul 2002 14:08:10 +0000 |
| Subject: | Something is wrong with my sessions.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108506@lists.php.net to get a copy of this message | ||
I must be missing something very basic here..
I login to my site successfully.. session values are created so I can
track/authenticate the user throughout the site:
login.php:
session_start();
(logic)
$VALID_USER = '1';
session_register("OL_VALID_USER");
(redirect to other page)
Then on the other page, the access is checked:
otherpage.php:
session_start();
require("functions.php");
check_access();
functions.php:
function check_access() {
global $VALID_USER;
if (session_is_registered("VALID_USER")) {
return true;
} else {
Header("Location: login.php");
exit();
}
}
Now, like I said, I login succesfully, the other page says I'm logged in
succesfully. But it seems to randomly lose track of my session as I
navigate the site. Even if -right- after I login, I manually type the URL
in the address bar to go to otherpage.php, where I was just authenticated,
the check fails and I am told to login again. I don't understand.. if I
refresh the page, the check works, but if I type the address in the location
bar of my browser to go there, it fails it. What is going on?
Thanks,
Chad