#36661 [NEW]: Session cannot change cookie_domain through ini_set
| From: | joshduck at hotmail dot com | Date: | Thu, 09 Mar 2006 06:54:49 +0000 |
| Subject: | #36661 [NEW]: Session cannot change cookie_domain through ini_set | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-94070@lists.php.net to get a copy of this message | ||
From: joshduck at hotmail dot com
Operating system: Windows XP
PHP version: 5.1.2
PHP Bug Type: Session related
Bug description: Session cannot change cookie_domain through ini_set
Description:
------------
PHP does not accept alternative cookie domains set through either
session_set_cookie_params or ini_set.
My test machine runs two sub domains 'www.example.com' and
'alt.example.com'. In my script I have tried to set the cookie domain to
'.example.com' (I've also tried 'example.com') so that both domains can
access the cookie. When the cookie is sent to the browser the domain is
set as the current domain ('www.example.com' or 'alt.example.com') rather
than what I specified.
I get the expected behaviour when I set session.cookie_domain in php.ini
or when I manually set a cookie.
Reproduce code:
---------------
<?php
session_set_cookie_params(6 * 3600, '/', '.example.com');
session_start();
print_r(session_get_cookie_params()); //Shows correct values
echo ini_get('session.cookie_domain') . '<br />'; //Outputs
'.example.com'
echo $_SESSION['blah'] . '<br />';
$_SESSION['blah'] = rand();
?>
php.ini:
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 1
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
Expected result:
----------------
Cookie domain (in client): example.com
Actual result:
--------------
Cookie domain (in client): www.example.com
--
Edit bug report at http://bugs.php.net/?id=36661&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36661&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36661&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36661&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36661&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36661&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36661&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36661&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36661&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36661&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36661&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36661&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36661&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36661&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36661&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36661&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36661&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36661&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36661&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36661&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36661&r=mysqlcfg