|
Posted by Jerry Stuckle on 05/02/07 11:56
K. A. wrote:
> On May 2, 11:39 am, Mike Roetgers <miker...@informatik.uni-bremen.de>
> wrote:
>> K. A. schrieb:
>>
>>
>>
>>> I have two servers at work, 'A' for testing and development, and
>>> server 'B' for production.
>>> On server A, I wrote a PHP test code to login users then direct them
>>> to a personalized page. This is done in 3 steps:
>>> Step 1. Normal http login page.
>>> Step 2. A page called login.php that takes the posted username, stores
>>> it as $_SESSION["username"], and registers it
>>> session_register("username"); user is taken to the personalized page
>>> according to his username and things are fine up to here. (this page
>>> is not displayed, only for redirecting purposes).
>>> Step 3. On the personalized page, I check whether session is started,
>>> then display a welcome message with the username. Session variables
>>> are passed across pages fine.
>>> Next, I did exactly the same steps on server B; at step 2 (above) user
>>> is directed to the correct page. But when I get to step 3, the session
>>> seems to lose or set all its variables to NULL (I checked this using
>>> var_dump($_SESSION)).
>>> The codes on server A and B are identical. I copied the php.ini file
>>> from server A to B (just in case there were differences) and restarted
>>> Apache on server B. But still, session variables are lost in Step 3
>>> although the session is still running.
>>> Any ideas why?
>> I guess session_register causes the problem.
>> You should read the "Caution"-boxes onhttp://php.net/session_register.- Hide quoted text -
>>
>> - Show quoted text -
>
> I tried removing session register but this turned out worse as it will
> store the session variable in the first place.
> I mean, before removing session_register, the value
> $_SESSION["userid"] was set to NULL, but without session_register, it
> will not even know that there is something called
> $_SESSION["userid"] !
>
> Still wondering why it will work on one server but not the other!
>
Which is how it should be. It's quite simple to see if the value has
been set with
if (isset($_SESSION['userid']) ...
I agree with Mike - the caution is there for a reason! Don't try to mix
and match.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|