|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-04-20 15:04 UTC] jani@php.net
[2009-04-20 19:23 UTC] scratch65535 at att dot net
[2009-04-20 21:13 UTC] scottmac@php.net
[2009-04-20 21:24 UTC] scratch65535 at att dot net
[2009-04-21 00:42 UTC] scottmac@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon May 18 22:00:01 2026 UTC |
Description: ------------ If localhost/p1.php initiates a session before redirecting to 127.0.0.1/p2.php (or vice versa), the session data will be saved in p1 but not restored in p2; a new session will be started in p2. Only if the host references match literally ( both 'localhost' or both '127.0.0.1' ) will the session be restored. Reproduce code: --------------- Create 2 files, truncate sessions for a clean start ( I store sessions in a mysql db, and 'incSessions.inc' are the vanilla routines that support that) _t1.php: <?php define('cDocRoot',$_SERVER['DOCUMENT_ROOT'].'/') ; require_once( cDocRoot.'Global/incSessions.inc' ) ; session_start() ; $_SESSION['T1'] = session_id() ; header('Location: http://127.0.0.1/_t2.php') ; exit() ; ?> _t2.php: <?php define('cDocRoot',$_SERVER['DOCUMENT_ROOT'].'/') ; require_once( cDocRoot.'Global/incSessions.inc' ) ; session_start() ; $_SESSION['T2'] = session_id() ; var_dump($_SESSION) ; exit() ; ?> Type into the address line of your browser "127.0.0.1/_t1.php", and note that var_dump shows both 'T1' and 'T2' having been set. Inspect the sessions storage, note that only one session was created. Re-truncate sessions, and call _t1 as "localhost/_t1.php". Note that var_dump now shows only 'T2' having a value, and that inspection of the sessions storage shows 2 sessions rather than 1. Expected result: ---------------- I expected the session to be restored after the redirect regardless of how localhost was identified. Actual result: -------------- See above