【发布时间】:2012-03-12 09:58:23
【问题描述】:
我目前正在处理会话超时问题。 在我的页面在特定时间不活动期间, 会话应该超时并返回登录页面。
我有这个代码。
// set timeout period in seconds
$inactive = 30;
// check to see if $_SESSION['timeout'] is set
$logger->debug("root|DEBUG3 accdetails_proc");
if(isset($_SESSION['timeout']) ) {
$session_life = time() - $_SESSION['timeout'];
if($session_life > $inactive)
{
session_destroy();
header("Location: ../../index.php");
///OR
//echo('<script type="text/javascript">');
//echo('top.location.href = "../../index.php"');
//echo('</script>');
}
else{ }
标头和回显都不起作用。超时时, 它在 session_destroy() 中停止并仍然执行回调, 因为我正在使用 ajax 调用这个文件。
如果我使用“回声”,则响应是:
<script type="text/javascript">top.location.href = "../../index.php"</script>');
在我的回调中解析时已经给出了错误。
如果我使用“标题”,它会返回我的登录页面的 html 但首先执行我的回调,所以它仍然给出错误 并且登录页面没有加载。
有人可以帮忙看看如何不执行 ajax 的回调 你销毁一个会话?
谢谢
【问题讨论】: