您在這裡

另一種多網域cookie登入問題的解法(不用寫入網址)

yelban's 的頭像
yelban 在 2007-07-24 (二) 20:17 發表

修改 settings.php
紅色為修改的部分
// 開頭的灰色部分是原始程式碼,供對照或以後還原

/**
* site/www.example.com/settings.php
* Hack by Jambo
**/

/**
* We try to set the correct cookie domain. If you are experiencing problems
* try commenting out the code below or specifying the cookie domain by hand.
*/
if (isset($_SERVER['HTTP_HOST'])) {
$domain = '.'. substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1);
//$domain = '.'. preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']);
// Per RFC 2109, cookie domains must contain at least one dot other than the
// first. For hosts such as 'localhost', we don't set a cookie domain.
if (count(explode('.', $domain)) > 1) {
//if (count(explode('.', $domain)) > 2) {
ini_set('session.cookie_domain', $domain);
}
}