From:             scratch65535 at att dot net
Operating system: W2KProSP4
PHP version:      5.2.9
PHP Bug Type:     Session related
Bug description:  Session not always restored after redirect

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

-- 
Edit bug report at http://bugs.php.net/?id=48026&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48026&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48026&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48026&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48026&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48026&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48026&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48026&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48026&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48026&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48026&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48026&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48026&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48026&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48026&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48026&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48026&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48026&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48026&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48026&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48026&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48026&r=mysqlcfg

Reply via email to