我们可以在 php.ini 中添加事件吗?就像我想注销一样。销毁我当前的会话并在单击按钮时删除现有的 cookie。按钮表单动作对应同页drum.php
<?php
$h=0;
if(isset($_COOKIE["name"])) {
if($h==0) {
session_start();
if(isset($_SESSION['views'])) {
$_SESSION['views']=$_SESSION['views']+1;
} else {
$_SESSION['views']=1;
}
echo "You have been logged in as: ".$_COOKIE["name"].".Your session will expire in "."5min."."You have viewed this page ".$_SESSION['views'];
} else {
session_destroy();
setcookie("name",$name,time()-25);
}
} else {
echo "<form action='drum.php' method='post'><input type='text' name='name'></input> ` </input><input type='submit' value='Log in'></input></form>";
$name=$_POST["name"];
$expire=time()+2*60;
setcookie("name",$name,$expire);
}
?>