|
Posted by Jerry Stuckle on 05/07/07 13:49
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?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|