note 55606 rejected from function.session-start by david
| From: | david@php.net | Date: | Thu, 20 Oct 2005 19:04:21 +0000 |
| Subject: | note 55606 rejected from function.session-start by david | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-97318@lists.php.net to get a copy of this message | ||
Note Submitter: foltscane at yahoo dot com
----
Many people were having trouble with PHP losing $_SESSION on header redirect. Most of the examples
did not set a session id. Before session_start() remember to put a session_id, this way it sets the
information to a place, and then calls on it from the same place.
page 1
<?php
session_id('8675309');
session_start();
$_SESSION['username']="USERNAME";
header(redirect......);
?>
page2
<?php
session_id('8675309');
session_start();
echo $_SESSION['username'];
?>
this way will not lose the data since you are telling it where to go and calling on it from the same
place.