【发布时间】:2011-02-07 17:33:24
【问题描述】:
我试图弄清楚为什么 Chrome 会发生这种情况,但 FF 或 IE 不会。 在以下脚本中,$this->referrer = $_SESSION['URL'];页面第一次加载时解析为 /,如果我刷新页面,它解析为 /404.php
function startSession(){
global $database; //The database connection
session_name("Training");
session_start(); //Tell PHP to start the session
/* Determine if user is logged in */
$this->logged_in = $this->checkLogin();
/**
* Set guest value to users not logged in, and update
* active guests table accordingly.
*/
if(!$this->logged_in){
$this->username = $_SESSION['username'] = GUEST_NAME;
$this->userlevel = GUEST_LEVEL;
$database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
}
/* Update users last active timestamp */
else{
$this->addLogCount($this->id);
$database->addActiveUser($this->username, $this->time);
}
/* Remove inactive visitors from database */
$database->removeInactiveUsers();
$database->removeInactiveGuests();
/* Set referrer page */
if(isset($_SESSION['URL'])){
$this->referrer = $_SESSION['URL'];
}else{
$this->referrer = "/";
}
/* Set current url */
$this->url = $_SESSION['URL'] = $_SERVER['PHP_SELF'];
}
对于 FF 和 IE,它首先解析为 /,然后解析为刷新时调用 startSession() 的页面地址。 chrome 处理这个问题的方式有什么我需要考虑的吗?
Chrome 中的 $session:
Session Object
(
[id] =>
[tracksid] =>
[username] => Guest
[userid] =>
[userlevel] => 0
[time] => 1297103371
[logged_in] =>
[userinfo] => Array
(
)
[url] => /Community/login.php
[referrer] => /404.php
[type] =>
[company] =>
[ip] =>
[badip] =>
)
在 FireFox 中的 $session:
Session Object
(
[id] =>
[tracksid] =>
[username] => Guest
[userid] =>
[userlevel] => 0
[time] => 1297096106
[logged_in] =>
[userinfo] => Array
(
)
[url] => /Community/login.php
[referrer] => /Community/login.php
[type] =>
[company] =>
[ip] =>
[badip] =>
)
【问题讨论】:
-
浏览器与会话无关。它只保存一个会话 ID。问题可能是一次多个请求吗?
-
我在 Chrome 中遇到了一些 cookie 问题,包括会话 cookie。它不能解决您的问题,但如果您能确定会话 cookie 是否设置正确,它可能会有所帮助
标签: php google-chrome