I have a PHP page called adminConnect.php, it has a session start as its first line, some includes and some functions. One of those functions is "ValidateLogin()", it will auto redirect the user to the homepage when the user does not have any sessions.
Here is the weird problem: Less then 1% of the time (when the page changes) my ValidateLogin wont detect the session and will redirect me to the homepage. If I hit back the page will load fine (the same function will be called) and ill be able to continue using my system.
Here is the start of the function that kicks me out < 1% of the time (ive confirmed it with the error_log line):
Here is the function (the echo should never be seen)
Code:
if (!(isset($_SESSION['csmsConnected'])))
{
error_log("csmsConnected session not set trigged. It should of auto redirected the user to the home page");
echo('<br/><h1 style="text-align: center">Error, you must be logged in to view this page.</h1>'); // user should never see this
header('Location: login.php');
exit();
}
Ideas? Between it appearing to happen randomly + it happening so few times I haven't been able to figure this one out. Its almost like my session_start(); isn't registering.
"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools."
-- Douglas Adams
I noticed this error both when from going from page to page and when my ajax checks to see if a user is still valid. Once again this might only happen 1 in 100 times.
It's telling you that the process running PHP does not have permission to write the data to the session directory/file on the disk. As to why it would only do that once in awhile, I have no idea. But take a look at the permissions/setting on the C:\php\sessiondata directory and see if anything catches your attention.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Sounds like it's a swap/tmp directory size issue - garbage collection isn't keeping up with server usage
If it was a permission issue it would happen all the time
Good point. Sounds like something to look into.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How would I look into that? This server has more than enough space and im not aware of anything that puts a constraint on the temp folder or anything. That also would not explain how it never happens two times in a row (in other words, if it was a size issue, what are the odds that in the 5s or so it takes me to hit back, it would be resolved 100% of the time?)
I am thinking of maybe upgrading PHP to latest version. But this is a live server, so I do not want to mess with it too much.
Now now I have to try this myself. Didn't realize up to now that too many groupings is a factor
What version of PHP are you using by the way? Is this standard install or you guys compile this yourselves? On php.ini you'll see settings for sessions perhaps you can play with it as to why you have "\\" on the session path.
Just out of curiosity is it possible that you might be switching domains between requests? Such as www.adomain.com with one request and then adomain.com for another? I have had some seemingly random session dropping due to that in the past.
Bookmarks