note 47383 added to ref.session

From: Date: Sun, 14 Nov 2004 16:50:17 +0000
Subject: note 47383 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-80515@lists.php.net to get a copy of this message
If you're using header('Location:' . $url) to redirect the user to another page, you should use session_write_close() to save session data before the redirect. $_SESSION is normally serialized and written to the harddrive when the script ends. Example: <?php $_SESSION["Message"] = "The task was completed."; session_write_close(); header('Location:' . $_SERVER["PHP_SELF"]); ?> Without session_write_close(), this next piece of code would not output "The task was completed". (Assuming that this code is in place where the user was redirected.) <?php echo $_SESSION["Message"]; ?> ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47383 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47383&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47383&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47383&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47383&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47383&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47383&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47383&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80515) next »