Re: sessions not registering inside a function.
| From: | John W. Holmes | Date: | Fri, 23 Jan 2004 16:38:42 +0000 |
| Subject: | Re: sessions not registering inside a function. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-175528@lists.php.net to get a copy of this message | ||
From: "Jarratt Ingram" <jarratt@easily.co.uk>
> I have created a login system, which works as expected on php 4.2. When
> i was asked to move it onto an older server using 4.0.6, the system
> stopped registering sessions.
>
> main page:
> <? session_start();
>
> function login($username, $password){
> global $HTTP_SESSION_VARS;
> session_register('AuthUser');
> $HTTP_SESSION_VARS['AuthUser'] = $username;
>
> This code was modified to backdate it to version 4.0.6, and now it wont
> register the session. Is it because its inside the function, or to do
> with the older version of php?
>
> If i move it out of the function the session gets registered correctly.
I think you're registering a variable that only has a scope within the
function. Try adding a "global $AuthUser;" after "global
$HTTP_SESSION_VARS;"
---John Holmes...