#15884 [Com]: session_unregister does not work when followed by header("Location: ...")

From: Date: Mon, 23 Apr 2007 07:25:09 +0000
Subject: #15884 [Com]: session_unregister does not work when followed by header("Location: ...")
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111798@lists.php.net to get a copy of this message
ID: 15884 Comment by: software_freedom at member dot fsf dot org Reported By: jt at domainfactory dot de Status: No Feedback Bug Type: Session related Operating System: Linux PHP Version: 4.1.2 New Comment: Hi Ho! Regarding my last post, I am sorry that it is completely a false report. The truth is that there is no such bug found in PHP version 4.4.0 (I am sorry that I also typed the wrong version before) that I use. The problem happened because in the first file (file A) I started a session under localhost, submitted form data to the second file (file B) which started a session under localhost also and set variable $_SESSION['error'] under it, but redirected to file A which started a session under experimental.ecc.org and checked whether variable $_SESSION['error'] was present under it. Because the session under experimental.ecc.org had not had $_SESSION['error'], file A reported that $_SESSION['error'] was not present. When I tried again by submitting the form to file B, my browser which read an HTML tag <BASE href="http://localhost/CDs/index.php"> sent the form data to file B under localhost and started a session under it along with setting $_SESSION['error'] variable in the session. Next, file B redirected the browser to file A which started a session under experimental.ecc.org and checked for the presence of non-existent variabel $_SESSION['error'] under it. This loop happened over and over again when I submitted the form data again and again because of my curiousity. I discovered all of these just before I started to recompile my PHP with --enable-debug flag when I tried once again using simpler version of file A and file B in which I hardcoded the url. For interested readers, I include the source code of file A (/CDs/index.php) and file B (/CDs/logic/login.php) below. Regards, Eus /CDs/index.php: <?php session_start (); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en-US" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta name="author" content="Eus" /> <meta name="copyright" content="&copy; 2007 Eus" /> <meta name="date" content="2007 March 10" /> <meta name="archive" content="Eus' index of Eus CDs' content" /> <meta name="content" content="Welcome page" /> <base href="http://localhost/CDs/index.php" /> <title> Welcome to Eus' index of Eus CDs' content </title> <style> h1 { text-align: center; border-style: solid; border-width: 0 0 thin 0; padding: 0 0 2% 0; } form { display: table; margin-left: auto; margin-right: auto; } form > div { display: table-row; } form > div > span { display: table-cell; } form > div > span.align_right { display: table-cell; text-align: right; } </style> </head> <body> <h1> Eus' CDs </h1> <p> Before you can browse or modify the index, please login into the database first using the login panel below. Thank you. </p> <?php if (isset ($_SESSION ['error'])) echo 'Yes!'; else echo 'No!'; if (isset ($_SESSION ['error'])) { ?> <ul class="error"> <?php foreach ($_SESSION ['error'] as $key => $value) { ?> <li> <?php echo $value . "\n"; ?> </li> <?php } ?> </ul> <?php } ?> <form action="logic/login.php" method="post"> <div> <span> <label> Username </label> </span> <span> <input type="text" name="username" /> </span> </div> <div> <span> <label> Password </label> </span> <span> <input type="password" name="password" /> </span> </div> <div> <span> <input type="reset" value="Reset" /> </span> <span class="align_right"> <input type="submit" value="Submit" /> </span> </div> </form> </body> </html> <?php unset ($_SESSION ['error']); ?> CDs/logic/login.php: <?php session_start (); if (!isset ($_POST ['username']) || !is_string ($_POST ['username']) || strlen (trim ($_POST ['username'])) < 1) { $_SESSION ['error'][] = 'username cannot be empty'; } if (!isset ($_POST ['password']) || !is_string ($_POST ['password']) || strlen (trim ($_POST ['password'])) < 1) { $_SESSION ['error'][] = 'password cannot be empty'; } session_commit (); //if (isset ($_SESSION ['error'])) { header ('Refresh: 5; url=http://' . $_SERVER ['SERVER_NAME'] . '/CDs/index.php'); //} ?> Previous Comments: ------------------------------------------------------------------------ [2007-03-15 18:19:05] software_freedom at member dot fsf dot org Yup! Same here! But, my code is something like the following: index.php: session_start (); if (isset($_SESSION ['wow'])) echo 'Yes! '; else echo 'No! '; echo '<a href="http://localhost/bug.php">Go!</a>'; bug.php: session_start (); $_SESSION ['wow'] = 'Alright!'; session_commit (); header ('Location: http://localhost/index.php'); The answer is always 'No! '. So, sad! I will try to submit the backtrace if I have time ;-) My PHP version is 4.1.14 ------------------------------------------------------------------------ [2002-06-01 00:00:06] php-bugs at lists dot php dot net No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2002-03-28 04:22:28] jt at domainfactory dot de Sorry but currently I am unable to provide a backtrace. Maybe anyone who stumbled over this bug and has a bit of time can provide one ? (Also I forgot my bug-password, beat me) Jochen ------------------------------------------------------------------------ [2002-03-26 21:48:24] yohgaki@php.net To properly diagnose this bug, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php Once you have generated a backtrace, please submit it to this bug report and change the status back to "Open". Could you try to get backtrace? I guess PHP is segfaulting. ------------------------------------------------------------------------ [2002-03-11 10:15:00] jt at domainfactory dot de Yup looks like the two are related. The other bug was submitted an Mar 6th, I submitted mine on Mar 5th so at least the dupe is not my fault ;) Jochen ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/15884 -- Edit this bug report at http://bugs.php.net/?id=15884&edit=1

« previous php.bugs (#111798) next »