Re: [PHP] Session Not Saving?

2002-09-29 Thread Chris Shiflett

I'm not sure why you are trying to use session_is_registered() to 
validate a user, but you should get rid of that.

With sessions, you want to start the session on every page you need 
session management. If you have a session module that you include 
everywhere, you can do this by registering each session variable, as 
that will implicitly start the session as well.

If you want to greet a user by name, simply have a session variable 
called "first_name" or something. Then, if it's not blank, greet them.

I'm not sure if that helps, but you at least need to rethink what you 
are trying to do.

Chris

Stephen Craton wrote:

>Here's the code
>that checks to see if the user is valid:
>
>function check_valid()
>{
>  global $valid_user;
>  if (session_is_registered("valid_user"))
>  {
>  echo "Welcome $valid_user!";
>  }
>  else
>  {
> echo "You are not logged in.";
> exit;
>  }  
>}
>


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




Re: [PHP] Session Not Saving?

2002-09-29 Thread debbie_dyer

Are you calling session_start() on the other pages inside the secure area?

- Original Message - 
From: "Stephen Craton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, September 29, 2002 5:23 PM
Subject: [PHP] Session Not Saving?


> I'm having another problem with my member's area script. When someone
> logs in, it's supposed to register their username into a session and it
> displays fine on the first page. But once you navigate to another part
> of the area, it does not tell you you are logged in, instead it gives me
> the error I set it to give "You are  not logged in." Here's the code
> that checks to see if the user is valid:
> 
> function check_valid()
> {
>   global $valid_user;
>   if (session_is_registered("valid_user"))
>   {
>   echo "Welcome $valid_user!";
>   }
>   else
>   {
>  echo "You are not logged in.";
>  exit;
>   }  
> }
> 
> Here's the code that's supposed to save the session:
> 
> include_once("funcs.php");
> session_start();
> if($user && $pass)
> {
> if(login($user, $pass))
> {
> $valid_user = $user;
> session_register("valid_user");
> }
> else
> {
> echo " size='3'>You supplied an invalid username and password combo.
> Try again please.";
> exit;
> }
> }
> 
> Please help again!!!
> 
> Thanks,
> Stephen
> http://www.melchior.us
> http://php.melchior.us
> 
> 
> 
> -- 
> 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




Re: [PHP] Session Not Saving?

2002-09-28 Thread Sascha Cunz

> function check_valid()
> {
>   global $valid_user;
>   if (session_is_registered("valid_user"))
>   {
>   echo "Welcome $valid_user!";
>   }
>   else
>   {
>  echo "You are not logged in.";
>  exit;
>   }
> }

try it like this:

function check_valid()
{
  global $valid_user;
  if (isset($_SESSION['valid_user']))
  {
...

Regards Sascha

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