我的 class.inc 文件:
<?php
class logout{
public function logout(){
$_SESSION = array();
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params["httponly"]);
}
session_destroy();
}
}
?>
用于我的注销代码:
session_start();
require($path."include/class.inc");
if(!empty($_GET['logout'])){
$object=new logout();
$object->logout();
$content='5;url='.$path.'index.php';
}
调用该logout
函数时,它会破坏会话,但会显示警告:
Warning: session_destroy(): Trying to destroy uninitialized session in class.inc on line 9
我无法排除故障,因为session_destroy()
在class.inc
.