Sunday, 18 August 2013

php $_SESSION variable being cleared in chrome

php $_SESSION variable being cleared in chrome

I have written a php website with login mechanism. When an user has used
correct username and user password, the php will give him/her a
$_SESSION['userid'].
in index.php, I used the following to check login:-
if (!($_SESSION['userid'])){?>
<script>
window.location='login.php';
</script>
<?php }?>
and it works fine for a long time.
Recently, I realize in Chrome, after a short period (e.g. a few minutes),
the browser clears the session variables, and therefore, no matter I
refresh the page or click other menu buttons leading to index.php?XXXX,
the check login java script works and kick me back to login.php. But such
clearing will not happen at firefox and IE.
I noted chrome have some special situations that when the favicon.ico is
missing, the browser will perform 301 redirection that clears all the
session. But I believe I have specified the correct file location by a
href="/favicon.ico" with the file present at root directory.
Refer to the above, would there be other possible reason that can avoid
chrome from clearing the session variables?

No comments:

Post a Comment