From:             greg dot solak at profiletwist dot com
Operating system: Linux
PHP version:      5.3.0
PHP Bug Type:     Session related
Bug description:  Session variables not saved after redirect, 
session_write_close(), die() used

Description:
------------
PHP SESSION variable $_SESSION['user_level'] is not saved after the page
is redirected using header(location: ...). Session_write_close()is used
right before redirect. After redirect die() is called. After a second
attempt at login, everything works!

Reproduce code:
---------------
<?php
// If login successfully ->

// Change session properties
$_SESSION['user_level'] = 7;
// Force session to save changes before redirection
session_write_close(); // REQUIRED
// Regenerate session id for security + fix bug in which some session
variables are lost during redirect
session_regenerate_id(true);
// Redirect to Access main page
header('Location: http://www.domain.com/access/main.php');
die();

?>

Expected result:
----------------
At the new page (the one the user was redirected to) the
$SESSION['user_level'] should == 7. However, the session variable was not
saved, as the user is redirected back to the login page. After a second
attempt at logging in, everything works as expected.

Actual result:
--------------
Redirected back to login page, because when php checked if the user had
the proper credentials

if ($_SESSION['user_level'] != 7) {
 // redirect back to login page
}

Other improtant information: session_start(); is called on every page.

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

Reply via email to