Hello,
I have a website for which users need to login/register. They fill in a login form on index.php page. If login information is correct, I set a session variable. The script that checks the login information:
session_start() ;
[...check user and pass and if ok do:]
$_SESSION['logged_in'] = 'yes';
$_SESSION['utilizator'] = $utilizator;
$_SESSION['cont']="elev";
header("Locatio n: elev.php?pg=aca sa&user=".$util izator);
die();
[...]
The above code always gets to setting the session variables if the account information was correct, I tested this.
On the pages available only to logged in users, I check if that session variable is set:
<?php
session_start() ;
if ( $_SESSION['logged_in'] != 'yes') {
header("Locatio n: index.php?err=n eautentificat") ;
}
?>
The login sometimes works, sometimes doesn't. If I insist on logging in time after time, at some point the variable stays set and the login works. Sometimes it works from the first attempt. When I enter the account, when browsing from one page to another, sometimes I get redirected to index.php as if the session variable was not set anymore. But if I hit the "Back" button, I appear to still be logged in.
This happens both in IE and Mozilla Firefox.
Any ideas for this strange behavior ?
I have a website for which users need to login/register. They fill in a login form on index.php page. If login information is correct, I set a session variable. The script that checks the login information:
session_start() ;
[...check user and pass and if ok do:]
$_SESSION['logged_in'] = 'yes';
$_SESSION['utilizator'] = $utilizator;
$_SESSION['cont']="elev";
header("Locatio n: elev.php?pg=aca sa&user=".$util izator);
die();
[...]
The above code always gets to setting the session variables if the account information was correct, I tested this.
On the pages available only to logged in users, I check if that session variable is set:
<?php
session_start() ;
if ( $_SESSION['logged_in'] != 'yes') {
header("Locatio n: index.php?err=n eautentificat") ;
}
?>
The login sometimes works, sometimes doesn't. If I insist on logging in time after time, at some point the variable stays set and the login works. Sometimes it works from the first attempt. When I enter the account, when browsing from one page to another, sometimes I get redirected to index.php as if the session variable was not set anymore. But if I hit the "Back" button, I appear to still be logged in.
This happens both in IE and Mozilla Firefox.
Any ideas for this strange behavior ?
Comment