我已經得到了用戶投入到細節會話變量登錄腳本之間傳遞。今天我把網站移到了新的主機上,現在我的編碼不起作用。這是我能做的最好的,它仍然無法正常工作
main_login.php:
(script above here gets all the $info from the database. So far it is working)
if($count==1){
session_start();
$_SESSION['username'] = $info['username'];
$_SESSION['given'] = $info['given_name'];
$_SESSION['family'] = $info['family_name'];
$_SESSION['profile'] = $info['profile'];
$_SESSION['adultchild'] = $info['adultchild'];
$_SESSION['id'] = $info['id'];
header("location:welcome.php");
}
的welcome.php:
// Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.
session_start();
if(!isset($_SESSION['username'])){
header("location:main_login.php");
}
麻煩的是,當我打印任何的會話變量沒有任何反應我甚至嘗試過做一個var_dump($_SESSION)
,但它作爲一個空陣列出現。坦率地說,我已經花了整整一天的時間,並被卡住了。
檢查您的配置,如果會話支持已啓用,並檢查您的cookie,如果'PHPSESSID'的cookie被設置在所有。 – 2013-03-04 09:23:00
可能它不會進入你的,如果($計數== 1),數組是空 – Johny 2013-03-04 09:24:13
您可能遇到的Cookie域設置錯了,所以該cookie被髮送沒有其他的解釋,但瀏覽器拒絕接受/發送cookie回因爲域名不是正確的。 – 2013-03-04 10:03:30