...

View Full Version : sessions/cookie question



mhunt
07-13-2007, 06:45 PM
I was wondering if there is a way to check if a cookie is expired because i want to do an auto logout script when the user is inactive for a certain amount of time. For testing purposes i made it 10 seconds. here is the code i have so far but it doesnt log you out.


$user = $_SERVER[PHP_AUTH_USER];
$pass = md5($_SERVER[PHP_AUTH_USER]);
if(($user) AND ($pass)) {

session_start();
setcookie("PHPSESSID", $_COOKIE['PHPSESSID'], time()+10);
echo $_COOKIE['PHPSESSID'];c
$_SESSION['user'] = $_SERVER[PHP_AUTH_USER];
$_SESSION['pass'] = md5($_SERVER[PHP_AUTH_USER]);
$_SESSION['userip'] = $_SERVER['REMOTE_ADDR'];
$sess_id = session_id();

if(!isset($_SESSION['timestamp'])) {
$_SESSION['timestamp']=time();
$result = $db->query("INSERT INTO user_tracking(id, user, ip, tstamp) VALUES('', '{$_SESSION['user']}', '{$_SESSION['userip']}', NOW())");
if(!$result) {
die("Error inserting user into tracking database".mysql_error());

}
}
if($_COOKIE['PHPSESSID']) {
echo "You are now being logged out due to inactivity";
session_destroy();
echo "<meta http-equiv=\"refresh\" content=\"5;url=http://www.midtownvillage.org/test.php\">";
}

}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum