【发布时间】:2014-07-01 17:43:06
【问题描述】:
我遇到了一个奇怪的错误。它与更新php会话有关。
我有一个网站,它的登录/注销在 chrome、safari 和 IE 等中都能完美运行。但在 Firefox 中它无法正常工作。当我使用 firefox 登录时,注销按钮似乎已死或什么的。它只是不让我注销。即使我手动输入注销链接,它仍然没有做任何事情并让我保持登录状态。我根本没有做任何复杂的事情。
知道为什么相同的代码在 chrome、IE 和 safari 中有效,但在 Firefox 中无效?
告诉我, 谢谢。
=============================注销代码================= ===============
public function logout() {
$this->session->unset_userdata('smallpoint_username');
$this->session->sess_destroy();
redirect(base_url() . 'forum/update_session.php?hasher = ' . time() . time() . time() . time() . time() . time() . '&&nohasher=' . time() . time() . time() . time() . time() . time() . '&&op=2', 'location', 301);
}
================登录中的会话设置代码========================== =====
$session_array = array(
'smallpoint_username' => $insertData['username'],
'smallpoint_full_name' => $insertData['full_name'],
'smallpoint_user_type' => $insertData['user_type'],
'smallpoint_user_id' => $userData['id'],
'smallpoint_user_snap' => '',
'is_logged_in' => 1,
);
$this->session->set_userdata($session_array);
redirect(base_url() . 'forum/update_session.php?hasher = ' . time() . time() . time() . time() . time() . time() . '&&nohasher=' . time() . time() . time() . time() . time() . time() . '&&thisisid=' . $userData['id'] . '&&thisisrole=' . $insertData['role'] . '&&thisisname=' . $insertData['username'] . '&&op=1', 'location', 301);
======================update_session.php======================
session_start();
require 'includes.php';
if ($_GET['op'] == 1) {
$_SESSION[TABLES_PREFIX . 'sforum_logged_in'] = true;
$_SESSION[TABLES_PREFIX . 'sforum_user_id'] = $_GET['thisisid'];
$_SESSION[TABLES_PREFIX . 'sforum_user_role'] = $_GET['thisisrole'];
$_SESSION[TABLES_PREFIX . 'sforum_user_username'] = $_GET['thisisname'];
} else {
unset($_SESSION[TABLES_PREFIX . 'sforum_logged_in']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_id']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_role']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_username']);
setcookie(TABLES_PREFIX . COOKIE_NAME, "", time() - 3600);
}
header('Location: ' . $_SERVER['HTTP_REFERER']);
【问题讨论】:
-
您是在使用带有 cookie 的会话,还是只使用 cookie?你能发布一些代码吗?请注意这两种方法如何要求浏览器接受 cookie?
-
我也添加了代码。看起来它也在使用 cookie。