Forum Moderators: coopster
Am new to PHP... I had created login form with session.. I wish to change my form as-"After idle time of 30 seconds session should expire and should go to login page once again"...
<?php
ini_set("session.gc_maxlifetime",30);
session_start();
if(session_is_registered('email'))
{
echo 'Login successful';
session_unset();
session_destroy();
}
else
{
header("location:main.html");
}
?>
I tried this code.... wat is the change that i have to do to achieve above said requirement...
Thanks,
Ramya
You could set something like -
$_SESSION['last_time'] = time();
if ($_SESSION['last_time']+30 >= time() {
// last login + 30 seconds greater than present time
// kill session
}
<edit>
You need to be careful when killing sessions as sometimes session_unset doesnt actually work so well.
function kill_session() {
$_SESSION = array();
session_unset;
session_destroy();
}
[edited by: PHP_Chimp at 6:21 pm (utc) on Dec. 26, 2007]