Hope someone might have some insight to this problem.
I've got a site I'm developing that has a login form that establishes a session using a function I've defined:
function establishSession($userInfo) {
global $sessionUvaComputingID;
global $sessionLastName;
global $sessionFirstName;
global $sessionEmailAddress;
global $sessionAccessLevelID;
session_name(SESSIONNAME);
session_set_cookie_params(SESSIONTIMEOUT);
// Set session variables for use in the application.
session_start();
$sessionUvaComputingID = $userInfo['uvaComputingID']; session_register("sessionUvaComputingID");
$sessionLastName = $userInfo['lastName'];
session_register("sessionLastName");
$sessionFirstName = $userInfo['firstName'];
session_register("sessionFirstName");
$sessionEmailAddress = $userInfo['emailAddress'];
session_register("sessionEmailAddress");
$sessionAccessLevelID = $userInfo['accessLevelID']; session_register("sessionAccessLevelID");
}
This function works fine and the site appears to work great. It loads two frames after login and each page has session code at the beginning:
session_name(SESSIONNAME);
session_set_cookie_params(SESSIONTIMEOUT);
session_start();
Frames reload as actions are taken in them. In each frame page there is code after the session is opened, checking to see if a session variable exists to determine if the session expired.
if (!session_is_registered("sessionUvaComputingID")) {
/ Remove the client session. /
session_destroy();
setcookie(SESSIONNAME,"","","/");
...
}
In one of the frames, there are files that are selectable and all (in a sample of test data - 994 records) can be selected. These items are tracked in a few session variables that are added when using that frame and the choosing items with checkboxes.
Here's the problem (which is random): the session appears to be timing out. Randomly the application will log itself out using the code just above. The code that checks for the session variable gets executed when the timeout associated with the session has not occurred. And it's random. I could be working an hour in the app or 10 minutes. I know this is the problem because the last user activity time is stored in a file (each time a frame is loaded a timestamp is updated in a table). The timestamp indicates that the timeout has not occurred.
I've been searching for information regarding issues with the session features in PHP and find none. Anyone else have this problem? Or am I coding something wrong?
Thanks,
Jack Kelly
jack@virginia.edu