【发布时间】:2016-04-01 04:26:07
【问题描述】:
我正在从 Angular 调用 logout.php 页面:
$scope.logout = function(){
$cookies.remove("isLoggedIn");
$http({ url : "./include/logout.php" }).then(function(response) {
alert(response.data)});
window.open("indexB.html", "_self");
}
这是 php:
<?php
echo 'test';
session_start();
session_destroy();
session_unset();
unset($_SESSION);
?>
当我单击注销按钮并调用注销函数时,我的“isLoggedIn”cookie 被删除,我收到“测试”警报,但 PHP 会话 cookie 不会删除。
【问题讨论】:
-
要使用基于 cookie 的会话,必须在向浏览器输出任何内容之前调用 session_start()。
-
我创建了一个名为 start.php 的文件,该文件在任何 html 输出到浏览器之前运行,启动会话,然后重定向到调用注销功能的页面。我仍然看到 and session_destroy() 仍然不起作用。