【发布时间】:2011-03-30 18:54:25
【问题描述】:
我正在使用此脚本登录用户,我想知道是否可以添加一个简单的 cookie,该 cookie 会在用户闲置 30 分钟后自动注销。
...
if($count){
session_start();
session_regenerate_id();
$_SESSION['SESS_USERNAME'] = $myusername;
$_SESSION['SESS_PASSWORD'] = $mypassword;
session_write_close();
header("location: login_success.php");
}
连接到:
<?php
session_start();
if(!isset($_SESSION['SESS_USERNAME']) || !isset($_SESSION['SESS_PASSWORD']) || (trim($_SESSION['SESS_USERNAME']) == '')) {
//someone's not logged in
header("location: index.php"); //it's suppose to actually be there
exit();
}
?>
然后结束会话:
<?php
session_start();
session_destroy();
?>
这可能吗?这个脚本是离线的,因为我对PHP了解不多,所以如果很难我不会打扰!
感谢您的宝贵时间!
【问题讨论】:
-
为什么这么多新用户用感叹号提问?
标签: php session-cookies