Re: Re: A common theme: sessions
| From: | Chesley A Windon | Date: | Thu, 11 Oct 2001 13:44:07 +0000 |
| Subject: | Re: Re: A common theme: sessions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70802@lists.php.net to get a copy of this message | ||
Tried this...
by reversing the order of the vars, setting them, then registering them,
made no difference. They still did not print.
The SID is being set initially. When I tried to read the SID when the
page was called a second time (after header()) SID was _not_ set. So I
tested for cookies. The page is trying to set a cookie even though I'm
trying _not_ to use cookies.
Ideas?
Thanks,
Chesley
> 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> */
> > ?>
> >
> >
>
>
>
>
--
Chesley A. Windon windon@theautusgroup.com
The Autus Group www.theautusgroup.com
274 South Third Street 614.358.0659
Columbus, OH 43215