Re: sessions failing to persist
| From: | Michael R. Wayne | Date: | Mon, 03 May 2004 05:05:46 +0000 |
| Subject: | Re: sessions failing to persist | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185164@lists.php.net to get a copy of this message | ||
On Mon, May 03, 2004 at 06:55:25AM +0200, Richard Harb wrote:
> If the sample of code is the whole page... where do you actually start
> your session?
I am using session.auto_start, which starts it for me. I added a
session_start while testing and it made no difference.
> session_is_registered(): mabe I'm reading the documentation wrong, but
> I interpret this function as checking whether there is the global var
> (in this case $stage) ... and since register_globals is off there
> shouldn't be such a var automatically any more.
> In the user comments there's a good example of how to handle sessions.
>
> http://www.php.net/session_is_registered#26464
OK, replaced it with the following, no change in behaviour. I still get
a new sessionID every time I hit Submit.
<?
if (!isset($_SESSION["stage"])) {
$_SESSION["stage"] = 0;
$_POST['field'] = "";
session_register("stage");
}
?>
<html>
<head><title>PHP Test page</title></head>
<body>
<?
echo "Stage:"; echo $_SESSION["stage"];
echo " SessionID: "; echo session_id();
$_SESSION["stage"] = 1;
?>
<form method=post action="xxx.php">
<input type=text maxlength=7 size=7 name=field value="<?echo
$_POST['field']?>">
<input type=submit value="Submit">
</form>
<?
echo "Stage:"; echo $_SESSION["stage"];
?>
</body> </html>