Re: Problem grabbing value of session
| From: | Kevin Stone | Date: | Tue, 16 Apr 2002 18:50:26 +0000 |
| Subject: | Re: Problem grabbing value of session | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93238@lists.php.net to get a copy of this message | ||
I think the problem is one of scope.. though I have never tried starting a
session inside a function so I really don't know how it operates. But if
you do something like..
/********************/
function is_valid($user, $privs)
{
// validate user..
if ($valid) {return TRUE;}
}
if (is_valid($user, $privs))
{
session_start();
session_register(user);
session_register(privs);
}
/********************/
I don't know the answer to your question but this work with out a doubt as
it avoids any unkown problems with the scope of the session variables.
-Kevin
----- Original Message -----
From: "Jeff Lewis" <jeff@hyrum.net>
To: <php-general@lists.php.net>
Sent: Tuesday, April 16, 2002 12:40 PM
Subject: [PHP] Problem grabbing value of session
> I am in a function called Login2 in which I call the following:
>
> session_start();
> session_register("valid_user");
> session_register("privs");
>
> valid_user contain a name - Jim
> privs contains a number -1
>
> Right after I call those I try a is_registered and it showed that these
> registered correctly. I removed that code and added a call to another
> function: redirectinternal();
>
> That function is below:
>
> function redirectinternal () {
> global $valid_user,$privs;
>
> echo "Login good!";
> echo "<BR>".$valid_user." - ".$privs.$temp;
>
> }
>
> Now, I can't seem to get those values to print to the screen. I added a
> session_start before the echo and I just can't get my values out...what am
I
> missing?
>
> Jeff
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>