Re: Checking Session Vars in Functions
| From: | lallous | Date: | Fri, 09 Aug 2002 11:13:12 +0000 |
| Subject: | Re: Checking Session Vars in Functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111787@lists.php.net to get a copy of this message | ||
try to check if a session is session or not via:
session_is_registered()
Elias
"Monty" <monty3@hotmail.com> wrote in message
news:B978F1E4.131C8%monty3@hotmail.com...
> I have PHP 4.2.2 with register_globals=off.
>
> It seems like session vars stored in $_SESSION[] aren't visible to
> functions. For example, this won't work for me:
>
> $status = user_access();
>
> function user_access() {
> if ( isset($_SESSION['user']) ) { return 1; }
> else { return 0; }
> }
>
> Result is that $status = 0 even though I know those session vars are set.
>
>
> if ( isset($_SESSION['user']) ) {
> echo "Logged In";
> } else {
> echo "Not Logged In";
> }
>
> Result for the above is "Logged In" even though I'm checking the same
> session var. My script does include session_start(); as well.
>
> So, is there a way I access session vars stores in $_SESSION[] from a
custom
> function? Thanks!
>
> Monty
>