1

I have a script to protect the webpages so that only registered member of my site access certain pages say i call that memberprotect.php and in that file itself i am adding an script that will keep the sesion active for 360 seconds and if the webpage is inactive for more that 360 seconds i want to redirect the page to logintimeout.php. but my problem is the script automatically taking the member page to loin.php instead of logintimeout.php pls help or sugest what i should do . pasting the entire script below

 <? 
 session_start();
 // set timeout period in seconds
 $inactive = 360;
 // check to see if $_SESSION['timeout'] is set
 if(isset($_SESSION['timeout']) ) {
$session_life = time() - $_SESSION['timeout'];
if($session_life > $inactive)
    { session_destroy(); 
 header('Location:logintimeout.php'); }
}
$_SESSION['timeout'] = time();
if(!session_is_registered(myusername))
{
header('location:login.php');
}
?> 
4

1 回答 1

0

当您发出位置标头时,您应该停止脚本继续执行。例如:

<?php
header("location:http://www.google.co.uk/");
exit();
?>
于 2013-02-01T16:35:45.303 回答