PHP Version 5.2.0-8+etch1
I have installed drupal on: http://www.mate.pl/ and http://www.ubercart.dev.mate.pl/
php $_COOKIE[session_name() returns cookie from domain .mate.pl instead of .ubercart.dev.mate.pl
How to test:
To test this, I added the following changes to session.inc at line 65-66 (debug)
$value .= ', $key='. $key;
$value .= ', $_COOKIE[session_name()='. $_COOKIE[session_name()];1) First I visit: http://www.mate.pl/
cookie from FF web developer:
http://www.ubercart.dev.mate.pl/node
1 cookie
Name PHPSESSID
Value 84f0544dc457badc077e14cb2a92376f
Host .mate.pl
Path /
Secure No
Expires 20 April 2007 15:04:27
cookie from php (print_r($_COOKIE);): http://www.ubercart.dev.mate.pl/cookie.php
Array
(
[PHPSESSID] => 84f0544dc457badc077e14cb2a92376f
)
sql:
mysql> select * from sessions;
Empty set (0.00 sec)
2) I visit http://www.ubercart.dev.mate.pl/
cookie from FF web developer:
http://www.ubercart.dev.mate.pl/
1 cookie
Name PHPSESSID
Value 84f0544dc457badc077e14cb2a92376f
Host .mate.pl
Path /
Secure No
Expires 20 april 2007 15:04:27
cookie from php (print_r($_COOKIE);): http://www.ubercart.dev.mate.pl/cookie.php
Array
(
[PHPSESSID] => 84f0544dc457badc077e14cb2a92376f
)
sql:
mysql> select * from sessions;
+-----+----------------------------------+-----------------+------------+-------+---------------------------------------------------------------------------------------------------+
| uid | sid | hostname | timestamp | cache | session |
+-----+----------------------------------+-----------------+------------+-------+---------------------------------------------------------------------------------------------------+
| 0 | 84f0544dc457badc077e14cb2a92376f | 213.180.128.171 | 1175074441 | 0 | , $key=84f0544dc457badc077e14cb2a92376f, $_COOKIE[session_name()=84f0544dc457badc077e14cb2a92376f |
+-----+----------------------------------+-----------------+------------+-------+---------------------------------------------------------------------------------------------------+
3) I try to login to http://www.ubercart.dev.mate.pl/
cookie from FF web developer:
http://www.ubercart.dev.mate.pl/node
2 cookies
Name PHPSESSID
Value 84f0544dc457badc077e14cb2a92376f
Host .mate.pl
Path /
Secure No
Expires 20 april 2007 15:04:27
Name PHPSESSID
Value 2d59f037639ebd6c8c6c35d4376feaae
Host .ubercart.dev.mate.pl
Path /
Secure No
Expires 20 april 2007 15:08:59
cookie from php (print_r($_COOKIE);): http://www.ubercart.dev.mate.pl/cookie.php
Array
(
[PHPSESSID] => 84f0544dc457badc077e14cb2a92376f
)
sql:
mysql> select * from sessions;
+-----+----------------------------------+-----------------+------------+-------+---------------------------------------------------------------------------------------------------+
| uid | sid | hostname | timestamp | cache | session |
+-----+----------------------------------+-----------------+------------+-------+---------------------------------------------------------------------------------------------------+
| 1 | 2d59f037639ebd6c8c6c35d4376feaae | 213.180.128.171 | 1175074538 | 0 | , $key=2d59f037639ebd6c8c6c35d4376feaae, $_COOKIE[session_name()=84f0544dc457badc077e14cb2a92376f |
| 0 | 84f0544dc457badc077e14cb2a92376f | 213.180.128.171 | 1175074538 | 0 | , $key=84f0544dc457badc077e14cb2a92376f, $_COOKIE[session_name()=84f0544dc457badc077e14cb2a92376f |
+-----+----------------------------------+-----------------+------------+-------+---------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
php $_COOKIE[session_name() returns the cookie from domain .mate.pl instead of .ubercart.dev.mate.pl
Comments
Comment #1
akentner commentedI running a multisite on 5.1 with following schema:
If you try to login at sub.area*.maindomain.org, you can't. Precisely, after a valid username and password, there is the login form again and no login error.
I did some tests and had a look on the http-headers (firebug rocks ;-) ) and found out, that www.maindomain.org and sub.area1.maindomain.org gets the same PHPSESSID by a cookie but sub.area1.maindomain.org gets an additional PHPSESSID, which looks like
www.maindomain.org
sub.area1.maindomain.org
Two PHPSESSIDs. And at the subdomains the wrong one is chosen. IMHO there is only one allowed. I think there's the rub. But I don't know where to fix that.
Comment #2
Zen commentedDuplicate of http://drupal.org/node/56357