RE: Sessions not working between documents (was: Sessions and switching between php and htm documents)
| From: | Cal Evans | Date: | Wed, 27 Feb 2002 14:57:35 +0000 |
| Subject: | RE: Sessions not working between documents (was: Sessions and switching between php and htm documents) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-86414@lists.php.net to get a copy of this message | ||
When you check your info page, do sessions automatically start? If not, make
sure you do a session_start(); in there somewhere before you start checking
things.
Not sure why (lost in the annuls of time) but I always manually start/stop
my sessions.
=C=
*
* Cal Evans
* Journeyman Programmer
* Techno-Mage
* http://www.calevans.com
*
-----Original Message-----
From: Dave [mailto:dave@hawk-systems.com]
Sent: Wednesday, February 27, 2002 8:10 AM
To: cal@calevans.com; php-general@lists.php.net
Subject: Sessions not working between documents (was: Sessions and
switching between php and htm documents)
further to this...
--enable-track-vars --enable-trans-sid are both set in the build...
using mod_php
register globals is on
>-----Original Message-----
>From: Dave [mailto:dave@hawk-systems.com]
>Sent: Wednesday, February 27, 2002 8:47 AM
>To: cal@calevans.com; php-general@lists.php.net
>Subject: RE: [PHP] Sessions and switching between php and htm documents
>
>
>tested the $HTTP_SESSION_VARS prior to sending, set just fine.
>changed the next page to php and tested for the session var... nothing.
>
>[in login.php]
><?
>session_start();
># database check in here
>if(match){
> $HTTP_SESSION_VARS["UserID_session"]=$txtUserID; #from form
>field for user
> $HTTP_SESSION_VARS["UserNum_session"]=$databaseresult; # from
>database result for user number
> header("Location: successlogin.php"); # or .htm - changed this
>to test if var was being passed
> exit;
>}else{
> header("Location: wrongpassword.htm");
> exit;
>}
>?>
>
>[in successlogin.php]
><?
>echo $HTTP_SESSION_VARS["SellerID_session"];
>?>
>
>if I check session_id() - it is the same in both pages. Variables
>just aren't getting stored/retrieved.
>
>ideas?
>
>as an aside, how do you destroy/start a new session with new session
>id? or do you just destroy the variables then use the same session id
>for the new session?
>
>Dave
>
>>Did you test and make sure the variable is set?
>>login.php
>> session_start();
>> $HTTP_SESSION_VARS["username"]=$formUserName;
>> echo $HTTP_SESSION_VARS["username"]
>> header("Location: displaypage.htm");
>>
>>Also, for grins ang giggles, make the middle page in the chain a HP, start
>>the session and test for the variable. If it does not work then the problem
>>is not the middle page being html.
>
>
>>Subject: [PHP] Sessions and switching between php and htm documents
>>
>>
>>login.htm
>> form submits information
>>
>>login.php
>> session_start();
>> $HTTP_SESSION_VARS["username"]=$formUserName;
>> header("Location: displaypage.htm");
>>
>>displaypage.htm
>> show some static stuff
>> links to formpage.htm
>>
>>formpage.htm
>> form submits information to form.php
>>
>>form.php
>> session_start();
>> echo $HTTP_SESSION_VARS["username"]; <- has no value
>>
>>
>