HTTP_SESSION_VARS has no scope within a function. Make it global
first...

function currentlogin()
{
  global $HTTP_SESSION_VARS;

  echo $HTTP_SESSION_VARS['name'];
  return;
}

---John Holmes...

> -----Original Message-----
> From: Tim Greenleaf [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 21, 2002 9:38 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Retrieving Session Variables
> 
> I am having a problem getting a session variable in the function
> (currentlogin) below.  I can process the script and in the else
statement
> "print ($HTTP_SESSION_VARS['name']);" the session variable is printed
but
> when the function tries to print the session variable, I get an error
> indicating an undefined variable.
> 
> If someone could help me out I would appreaciate it.  Is there a good
> tutorial on how to set and get session variables.  From some of the
> snippets
> I have read in this news group there appears to be several ways to
> accomplish this.
> 
> Thanks
> 
> <?php
> if (isset($HTTP_SESSION_VARS['name'])==false){
>         writelogin();
>     }
>     else {
>       //Get logged in name and display message asking user if they
would
> like to log out
>         print ($HTTP_SESSION_VARS['name']);
>         currentlogin();
>     }
> 
> 
>     function currentlogin()
>     {
>     print ($HTTP_SESSION_VARS['name']);
>     return;
>     }
> 
> ?>
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to