|
Posted by Jerry Stuckle on 05/07/07 22:11
K. A. wrote:
> On May 7, 5:49 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> K. A. wrote:
>>> On May 6, 6:29 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>>>> Back again,
>>>>> I guess I know where the problem is. I found out that session
>>>>> variables are somewhat lost when I use the "header" function as in:
>>>>> header('Location:http://example.com/test/testvariables.php);
>>>>> User is correctly taken to the personalised page using the above line,
>>>>> but then the session variables get lost!
>>>>> My question now is: once I found out the userid and I know what page
>>>>> to take him to, what is the best way to re-direct him to that page
>>>>> without losing session variables?
>>>> Do you have session_start() at the beginning of the new page, also?
>>> Yes, I do have session_start(); first thing in all of my php pages.
>>>> If you're set up to use cookies to store the session id, this should
>>>> have no effect on session variables.
>>> Sorry, I did not get you!
>>> K.A.
>> PHP needs a way to keep track of the id for your session. It can do
>> this with cookies (most common) or by adding the session id as a query
>> parameter to your URI.
>>
>> If you're using cookies (most common), a redirect should not make any
>> difference. However, if you're not, the session id may get lost.
>>
>> One other thing - are you redirecting to the same domain, using the same
>> protocol, etc.?
>>
>> How about showing us the actual code you're using?
>
> The code is displayed above, just scroll up. I found out (from php.net
> discussions) that this is a common problem, so it is not just me.
> Yes, I'm redirecting to the same domain.
>
> I guess I'm going to try using cookies. Will try that when I get to
> work tomorrow.
>
I see some code posted above - but is this ALL of your code? For
instance, you have:
3. testvariables.php
// User is successfully directed to the right page, page opens up.
<?php
if (session_start())
echo "<p>session started</p>";
echo "<p> UserName: ( " . $_SESSION["userid"]. " )</p>";
echo "<p> Password: ( " . $_SESSION["password"]. " )</p>";
Is this ALL of the code? Where are the <head></head><body> tags, for
instance? Do you not have them in there?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|