Re: global variables, sessions, cookie, includes
| From: | burk at pobox dot com | Date: | Sun, 11 Jun 2000 11:06:04 +0000 |
| Subject: | Re: global variables, sessions, cookie, includes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1560@lists.php.net to get a copy of this message | ||
On Sun, 11 Jun 2000, Seth Lepzelter wrote:
> I've run into a problem with this though. It seems that session
> variables, and cookie data is not available to the included file. for
> example:
>
> in the included file,
> function isLoggedIn(){
> if((isset($HTTP_COOKIES_VARS['user'])) &&
> (isset($HTTP_COOKIES_VARS['pass']))){
> return 1;
> }
> return 0;
> }
>
> returns 0 even though those cookies are there.
>
> however, in the top-level file,
>
> if(!(isset($HTTP_COOKIE_VARS['user'])) &&
> (isset($HTTP_COOKIE_VARS['pass']))){
> print_expired();
> }
>
> works correctly(calls print expired if the cookies are not there, and
> doesnt if they are...).
>
> Am I missing something here?
The global variables have to be declared in the function with
function isLoggedIn(){
global $HTTP_COOKIE_VARS;
// etc.....
}
before you use them in the function. That's why you see them in the main
block of code but not in the function.
HTH
-burk
--
burk@pobox.com
Linux File Managers: http://www.pobox.com/~burk/linuxfile.html