Hi Curt,

        I'm confused..

<quote>
 With $_SESSION, there is no need to use the session_register(),
 session_unregister(), session_is_registered() functions. Session
 variables are accessible like any other variables. 
</quote>

        I'm using

session_start();
session_register('username');
$_SESSION['username'] = $row['username'];
session_register('user_id');
$_SESSION['user_id'] = $row['user_id'];
session_register('access_level');
$_SESSION['access_level'] = $row['access_level'];

and checking if user is authenticated using

if ( session_is_registered('user_id') ) 
        {
                return true;
        }
        else
        {       
                return false;
        }


Am I in error? (I'm trying to code using register_globals=off)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-----Original Message-----
From: Curt Zirzow [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 12:20 PM
To: PHP
Subject: Re: [PHP] Re: Redirection Question (I spoke to soon)


* Thus wrote Beauford.2005 ([EMAIL PROTECTED]):
> Sorry all, apparently this doesn't work on either Windows or Linux.
> Again, I thought it was working and once I got farther along I see that
> it really wasn't. Basically what I get after I login is an empty screen.
> Here is what I have :
> 
> This is the script that runs to see if the user is logged in.
> 
> session_start();
> if(!$_SESSION['logged']) {  
> 
>       session_register('goto');
>       $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] .
> $_SERVER['REQUEST_URI'];
> 
>       $url = "http://www.mysite.org/login/login.php";;
>       header("Location: $url"); 
> }
> 
> The above works and redirects me to the login page and has the right
> referring page as shown below.
> 
> goto|s:59:"http://www.mysite.org/setup/inputs.php";;
> 
> This is in my login.php script. After I verify the user login is
> correct, this piece of code is executed.
> 
>               session_start();
>             session_register('logged');
>             session_register('user');  

You don't need those two lines, they are only needed if ini.register_globals
is on and you want the variables $logged and $user to automatically be
sessioned as:
  $_SESSION['logged'] 
  $_SESSION['user'] 

<quote>
 With $_SESSION, there is no need to use the session_register(),
 session_unregister(), session_is_registered() functions. Session
 variables are accessible like any other variables. 
</quote>

I think this is were your problem is.

Also what php version?
<quote CAUTION>
If you are using $_SESSION and disable register_globals, do not use
session_register(), session_is_registered() and session_unregister(), if
your scripts shall work in PHP 4.2 and earlier. You can use these
functions in 4.3 and later. 
</quote>


Hmm.. After looking at the session_* documentation there are CAUTIONS
all over the place......  The all seem to say dont use sesion_register,
unregister, and is_registered when your using $_SESSION;


>                         
>             $_SESSION['logged'] = "True";
>             $_SESSION['user'] = $row['user'];
>                         
>             $target = "Location: " . $_SESSION['goto'];
> 
>             session_unregister('goto');

Use: unset($_SESSION['goto']);

>                         
>             header($target);
what does echo($target) yeild?

> 
> What I get after this is a blank page. The user has been logged in and
> shows in the session file, but it just isn't redirecting.
> 

HTH,

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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

Reply via email to