Re: A common theme: sessions

From: Date: Wed, 10 Oct 2001 23:44:21 +0000
Subject: Re: A common theme: sessions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70743@lists.php.net to get a copy of this message
ok two things I see, create the vars then register them, not visa versa. $UserID=$row["UserName"]; $CID=$row["CustID"]; $StatID=$row["$Status"]; session_register('UserID'); session_register('CID'); session_register('Status'); second, your not sending the SID as you think you are. header ("Location: $PHPSELF?". SID); even better is make sure SID is accually set, if cookies are being used SID wont be set. $PHPSESSID = session_id(); $SID = "PHPSESSID=$PHPSESSID"; header ("Location: $PHPSELF?$SID"); try that. -- Chris Lee lee@mediawaveonline.com "Chesley A Windon" <windon@orthus.net> wrote in message news:Pine.LNX.4.33.0110101216450.8139-100000@oak.autus.lan... > Hello All: > > It seems that there is a common theme on the list with session handling > right now. Unfortunately, this post is no different. > > I have a single script that calls itself ($PHPSELF) for authentication > against a MySQL database. I can register session variables and print the > values, but when I reload the page it seems as if the values are lost. > Code Follows. > > TIA, > > Chesley > > > <? > /* <snip> */ > > session_start(); > > session_register('UserID'); > session_register('CID'); > session_register('Status'); > > // Tried this also with no better result > // $HTTP_SESSION_VARS["UserID"]=$row["UserName"]; > // $HTTP_SESSION_VARS["CID"]=$row["CustID"]; > // $HTTP_SESSION_VARS["StatID"]=$row["StatID"]; > > $UserID=$row["UserName"]; > $CID=$row["CustID"]; > $StatID=$row["$Status"]; > > // This works, so I know there is data in the $row array > echo $row["UserName"]; > echo $row["CustID"]; > echo $row["StatID"]; > > header ("Location: $PHPSELF?SID"); > > /* <snip> */ > > // After the script calls itself I check for $PHPSESSID then do something. > if ($PHPSESSID) { > session_start(); > htmlheader(); > // for debug purposes > echo "Testing to make sure the conditional was true...It was."; > // Does not print anything... > while (list($var, $value) = each($HTTP_SESSION_VARS)) { > echo "$var = $value<br>\n"; > } > htmlfooter(); > } > > /* <snip> */ > ?> > >

« previous php.general (#70743) next »