2012-01-29 107 views
0

我設置了.htaccess將me.example.com重定向到example.com/fun/index.php。這個index.php有一個會話。當用戶使用me.example.com/index.php時,該會話從未啓用,但在example.com/fun/index.php上啓用。使用PHP登錄subdomain.example.com的會話

如何在me.example.com/index.php路徑上啓用會話。

回答

2
ini_set('session.cookie_domain', '.example.com'); 
+0

出於某種原因,這是行不通 – X10nD 2012-01-29 06:56:01

+0

不要忘記添加在session_start();在頁面的頭部,並嘗試用您的子域替換字符串.example – Ashraf 2012-01-29 07:04:54

+0

看看這裏:http://stackoverflow.com/questions/4631803/php-multi-domain-sessions-ini-set-not -加工 – Ashraf 2012-01-29 07:06:07

1
session_set_cookie_params(3600, '/', '.example.com'); 
session_start();