我有这段代码,但我不知道如何在PHP中闲置x分钟后才能添加注销
登录页面:
<html>
<head>
<title>login</title>
</head>
<body>
<form action="page1.php" method="get" >
ID:<input type="text" name="id" />
Password:<input type="password" name="pass" />
<input type="submit" value="login" />
</form>
</body>
</html>
获取页面:
<html>
<head>
<title> get</title>
<body>
<?php
session_start();
$get_id= $_GET['id'];
$get_pass = $_GET['pass'];
$_SESSION['user_id']=$get_id;
$_SESSION['user_pass']=$get_pass;
echo "welcome";
?>
</body>
</html>
现在我要在闲置10分钟后将此代码注销
您需要使用JavaScript进行计数,例如在x分钟后重定向到注销页面。
例子
<script>
function logout() {
window.location.replace("http://example.com/logout.php");
}
setTimeout(logout(), 10*60000);
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句