Sessions/Caching problem with Firefox 2.0.0.4
Moderator: General Moderators
Sessions/Caching problem with Firefox 2.0.0.4
I'm been having some problems with sessions, and I'm not sure what's going on. Everything has worked fine while I've been developing my site, but I just put it up on my department's web site (I work for a university) and I experienced some problems when trying to use it from home.
Without going into a ton of detail, sessions aren't working properly. It seems like Firefox is loading cached pages one time and not doing it the next. I'll perform some actions which should reset my sessions but the result uses the previous action's sessions instead. If I repeat, it will then work. But the same problem will occur the next time.
What's more, this is only happening at my apartment when using Firefox. IE works. I've tried using Firefox at a friend's place and it is fine.
So I'm thinking this may be a proxy thing, maybe? I would like to ensure that pages are never cached, since they are dynamically generated php anyways. I have control over the Apache and PHP 5 config files on the server, so if there's something I can do with those, that would be pretty easy.
Sorry if I'm being vague on the problem, I'm just not sure what could be causing a problem like this.
Without going into a ton of detail, sessions aren't working properly. It seems like Firefox is loading cached pages one time and not doing it the next. I'll perform some actions which should reset my sessions but the result uses the previous action's sessions instead. If I repeat, it will then work. But the same problem will occur the next time.
What's more, this is only happening at my apartment when using Firefox. IE works. I've tried using Firefox at a friend's place and it is fine.
So I'm thinking this may be a proxy thing, maybe? I would like to ensure that pages are never cached, since they are dynamically generated php anyways. I have control over the Apache and PHP 5 config files on the server, so if there's something I can do with those, that would be pretty easy.
Sorry if I'm being vague on the problem, I'm just not sure what could be causing a problem like this.
Well, I found a fix. Before, I was using some javascript to redirect the user after they submitted a form.
For some reason, the session variable would not get set every time. To fix this, I put a 100 ms delay in before the javascript redirection, so that the session would be sure to set itself.
It now works fine, except I'm not too thrilled about the way I solved it. I'm still not sure exactly what is going on, but I guess the client is executing the javascript before the session updates and thus, the session doesn't update at all.
Any ideas on what is actually happening and if there is a more elegant way to solve it? thanks
Code: Select all
if($_POST['submit']){
$_SESSION = $_POST['searchCriteria'];
_js("location.href = 'nextPage.php'"); //my javascript function
}Code: Select all
if($_POST['submit']){
$_SESSION = $_POST['searchCriteria'];
_js("SetTimeout('location.href=nextPage.php',100)"); //my javascript function
}Any ideas on what is actually happening and if there is a more elegant way to solve it? thanks
feyd | Please use
The problem wasn't fixed, however, until I put the delay in there. Is there something I have to do in the php.ini in addition to this?
Also, I forgot to mention, that it must not have been a proxy issue, because I was able to duplicate the error by opening two windows at the same time and submitting forms in each simultaneously.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I did read it, and I'm doing this before each page load.Code: Select all
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");The problem wasn't fixed, however, until I put the delay in there. Is there something I have to do in the php.ini in addition to this?
Also, I forgot to mention, that it must not have been a proxy issue, because I was able to duplicate the error by opening two windows at the same time and submitting forms in each simultaneously.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Thanks. The following code fixed things for me without using that ugly javscript delay.
I found this, of course, in the link you provided for me. Sorry that you had to tell me three times
Code: Select all
session_write_close();
header("Location: nextPage.php");I found this, of course, in the link you provided for me. Sorry that you had to tell me three times