我已经环顾四周,似乎在这里有一个独特的问题(对此有新意见,所以请关注此事)
我有一个注销功能,我将其用作注册系统的一部分,我将它放在一起。问题是,它在使用IE和Safari时失败(在点击适当的链接后仍然显示用户登录主页)。显然这里出现了问题,但是通过多次查看代码,它似乎没有任何错误吗?我的问题是为什么这在IE和Safari中不起作用?它是否与浏览器支持有关?
这是适用的代码:
**logout.php**
<?php
include_once 'functions.php';
sec_session_start();
// Unset all session values
$_SESSION = array();
// get session parameters
$params = session_get_cookie_params();
// Delete the actual cookie.
setcookie(session_name(), '', time()-42000,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]);
// Destroy session
session_destroy();
header('Location: ../index.php');
Appropriate function in **functions.php**
function sec_session_start() {
$session_name = 'sec_session_id'; // Set a custom session name
$secure = SECURE;
// This stops JavaScript being able to access the session id.
$httponly = true;
// Forces sessions to only use cookies.
if (ini_set('session.use_only_cookies', 1) === FALSE) {
header("Location: ../error.php?err=Could not initiate a safe session
(ini_set)");
exit();
}
// Gets current cookies params.
$cookieParams = session_get_cookie_params();
session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"],
$cookieParams["domain"], $secure, $httponly);
// Sets the session name to the one set above.
session_name($session_name);
session_start(); // Start the PHP session
session_regenerate_id(); // regenerated the session, delete the old one.
}
我已添加评论,以便更容易理解。
提前致谢!