I don't know if there is something unstable about using $_SESSION variables or not, but I've written user management scripts for my website, most of the time everything works okay but sometimes my server goes off on it's own and I can't load any pages on my server until I shut the server down and restart it.

I'm using: Apache/2.2.15 (Win32) PHP/5.3.2

The problem isn't just happening in one script but I've noticed some common threads.

I see the error when I send information from a form in login.php via POST to plogin.php which then validates the user and sets four SESSION variables before using javascript to redirect to a new page.

I've also seen the error once when I sent data from the client sign-up form to a different login script that inserts the user into the mySQL database and then sets the four SESSION variables.

It seems to happen more often when I log out as one user and log in as a new user, and almost anytime I use the back button on my browser.

I can log in and out a dozen times and it will never have a problem. Once logged in the variables get passed from page to page with no problems. It's only when I'm initially setting the variables that the problem seems to crop up.

Possible contributors: incorrect Apache configuration, using redirect with SESSION variables, using SESSION variables in the first place, every time I retrieve information from the database I create a new connection and then close it again.

I can provide some of the code if anyone thinks it will help, but you have to realize that there are about five files involved and each one is about 300 lines long. I've created a total of 37 pages so far(I've just started) but this problem is moving from just annoying to a point where it's slowing down the creation process. If I have to re-write the code I'd prefer to do it before I get a lot of work invested.

Now, here is some code:

The method I use to redirect is:


The four variables are:

$_SESSION (can't see anything possibly colliding with that var name)

The method I use for database access is:

function popquery($sql)
 if (!$con)
   die('Could not connect: ' . mysql_error());
 if (!$rturn)
   die('No data returned.');
 return $rturn;

I've told myself it's probably not a code issue since it would do it everytime if it were, but I don't really know how to trace this bug down.

BTW, when the error happens my browser says: "Waiting for"
Fiddler says: "

Can you believe I can't get the stupid thing to fail now?

Fiddler gives a message that no data was returned.

The Apache server-status page normally shows 2 Ws, but when the error happens the connections don't close and each time you click refresh or a link or try to access any page on the server you get another W that doesn't go away until you shut the server down and restart it.

Anyway, I'm about crazy from this so if anyone has run into this please put me on the right track. Otherwise I'm gonna start writing the damn variables to a text file on the hard drive. :)


Recommended Answers

All 2 Replies

it certainly isnt a code error becuase the php is parsing at the server, and the script is user side.

What exactly are you serving from? do you have all of the relevant ports open?

Thanks for the reply, I should have marked this one solved.

It turns out there was something wrong with my Apache server's configuration. In a fit of desperation(I was getting unreasonable errors) I uninstalled Apache and PHP, deleted all configuration files and re-installed everything. Viola, haven't had a problem since.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.