Hi.
I´m having problems with authentication.
Suppose page A calls page B and B calls C. Like this.
A ==> B ==> C
In page B, I have to ask the user for his username and pw, so that C will show him his data. Every time user passes though page B, I have to ask for his username and password. This way, I can switch between users without leaving the environment.
I have tried this:
if (! $flag || !isset ($PHP_AUTH_USER) || ! isset ($PHP_AUTH_USER))
{
header('WWW-Authenticate: Basic realm="Here"');
session_register ("flag");
$flag = false;
}
Did not work. Maybe my session variables are not correctly registered ?
Thanks
Leonel
How do I detect if it is the first time a user sees a page ?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Have you put session_start() at the top of each page that needs to use or set session variables? Another thing you might try is instead of:
If you have PHP 4.1 or above:
or if you have PHP 4.0.6 or below:
then you can prevent someone from putting a value for $flag in the URL's query string and authenticating themselves since flag is a fairly easy variable for someone to guess.
Mac
Code: Select all
session_register ("flag");
$flag = false;Code: Select all
$_SESSIONї'flag'] = false;Code: Select all
$HTTP_SESSION_VARSї'flag'] = falseMac
Code: Select all
<?php
if (session_is_registered("flag")) {
//user has revisited tha page
}
?>