我面临一个奇怪的错误。它与更新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 ====================== < / p>
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']);
答案 0 :(得分:0)
尝试将以下内容添加到您的代码中。
session_save_path("/tmp");
session_start();
我在firefox中遇到了同样的问题而且工作正常
session_save_path("/tmp"); // CREATE this Folder in the root
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']);