Re: sessions failing to persist

From: Date: Mon, 03 May 2004 04:55:25 +0000
Subject: Re: sessions failing to persist
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185163@lists.php.net to get a copy of this message
If the sample of code is the whole page... where do you actually start your session? I didn't see a session_start() anywhere. AFAIK the $_SESSION var doesn't exist until you do just that. 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 hth Richard Monday, May 3, 2004, 6:40:18 AM, thus was written: > As I posted last week, I seem unable to have sessions persist. I > have ruled out https as a problem, the following simple script, > installed as xxx.php will generate a new session number every time > the field is filled in and "Submit" is hit. > Note that I am not using cookies, the relevant session variables are: > Session Support enabled > session.auto_start On > session.use_cookies Off > session.use_trans_sid On > When run, the session file appears to contain stage=1 but never is being > read. > I suspect I'm missing something obvious, any pointers? > /\/\ \/\/ > <? > if (!session_is_registered("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>

« previous php.general (#185163) next »