Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Intermittent problems with user sessions

3 views
Skip to first unread message

stirrell

unread,
Oct 20, 2009, 8:23:42 AM10/20/09
to
Hello,

We have a website where groups of people will log on, answer questions
and compose prose. We are using standard PHP sessions to track the
users after logging in. Unfortunately, we have been having trouble
with people being logged out intermittently on the site. They go to
answer a question and are kicked back to the homepage because the page
is not retrieving their session information. The length of the session
does not seem to be a factor... some people seem to have fairly
lengthy sessions before experiencing this problem and some people are
kicked out almost immediately.

The site this is happening on is a shared server at Rackspace running
Apache 2.0.52, PHP 5.2.10 and MySQL 5.0.84. The server has memcache
installed but we have removed memcache from this site in the hopes of
tracking down this problem.

When a user logs into the site, a session variable is set with their
personId from the MySQL table:

$_SESSION['pid'] = $row['personId'];

At the top of each page, nested within a couple of includes, there is
a session_start() call. At the top of each question or prose page, we
check for the existence of the user's $_SESSION['pid'] variable and,
if they don't have one, kick them back to the index page:

if ($_SESSION['pid'] > 0) {
$studentData = getUser($_SESSION['pid']);
} else {
$sessionText = implode(", ",$_SESSION);
$sessionText .= "\n\n".$_SERVER['HTTP_REFERER'];
$mailto = "us...@domain.com
$subject = "Time-out error";
if (strstr($_SERVER['HTTP_REFERER'], "domain.com")) {
mail($mailto,$subject,
$sessionText,"From: no-r...@domain.com");
} // end of if
header("location: index.php?m=1");
exit;
}

So we are having a copy of the referrer page and the referrer sent to
us on failure along with the SESSION information. I have not seen any
kind of pattern from these error emails - they seem to come from all
different pages within the site and they do not have any SESSION
information - I just receive the current page and the referrer page.

Does anyone have any ideas as to why the session may be failing
intermittently? The issue does not seem to be the creation of the
sessions as people can log in... it seems to be a problem receiving
the session from time to time. Any help in this matter would be
greatly appreciated. We had originally had a custom session handler
using the database but we were experiencing the same problems.

0 new messages