View Full Version : sessions/cookie question

07-13-2007, 05: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.

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

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

if(!isset($_SESSION['timestamp'])) {
$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());

echo "You are now being logged out due to inactivity";
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