|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-09 21:11 UTC] mike@php.net
[2006-03-10 03:57 UTC] joshduck at hotmail dot com
[2006-03-10 13:30 UTC] mike@php.net
[2006-03-12 11:02 UTC] joshduck at hotmail dot com
[2006-03-12 11:03 UTC] joshduck at hotmail dot com
[2006-03-12 11:31 UTC] mike@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 23:00:02 2025 UTC |
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