Php 如何在会话超时时自动重新加载页面
我想在会话在php中获得timedout时自动取消设置会话变量并重新加载index.php。如何实现这一点Php 如何在会话超时时自动重新加载页面,php,session,Php,Session,我想在会话在php中获得timedout时自动取消设置会话变量并重新加载index.php。如何实现这一点 <?php session_start(); ?> <html> //html code </html> //html代码 设置JavaScript计时器,如果希望销毁会话,请使用此计时器: <?php session_destroy(); header("Location: index.php"); ?> 当页面加载时,您需要确
<?php
session_start();
?>
<html>
//html code
</html>
//html代码
设置JavaScript计时器,如果希望销毁会话,请使用此计时器:
<?php
session_destroy();
header("Location: index.php");
?>
当页面加载时,您需要确定会话中剩余的时间,并在此时设置Javascript计时器以将用户重定向到“注销”,该“注销”调用
会话_destroy()
,然后重定向回(注销)主页
JavaScript
//If there is one minute left for the session to expire...
//The actual value that should go where "60000" is should
//be calculated by PHP that renders this code.
setTimeout(function(){
window.location='doLogout.php';
}, 60000);
PHP(doLogout.PHP)
我会在超时后刷新页面。
请看你能详细说明一下怎么做吗?好吧,如果你想在超时时取消会话,你需要实现一些javascript,我想可能会调用某个PHP文件?此php文件会破坏会话并重定向到index.php或类似的内容。由于安全原因,在许多浏览器上不再工作。IDN不知道。有没有浏览器不支持它的来源?现在我手机上有,但IE不支持,我相信firefox也不支持
<?php
session_destroy();
header("Location: index.php");
?>