Hi,
I have two scripts that I use for user authentication.
The main script:
I register a session variable called 'uid' before the header of the
script:
i.e.
session_start();
if (!$PHPSESSID)
{
session_register('uid');
}
The rest of the script writes out two text boxes:
a username text box and a password text box.
The user enters their username and password and clicks on a submit
button.
When the submit button is clicked a function (in another php script -
call it 'script B' is called). This function is defined as:
function authenticate_user($username,$password)
{
global $uid;
...
...
...
<if successful>
$uid = $username;
...
return true;
}
I know the $uid is set within the above function (residing in script 😎
since I can echo the result to the screen.
The function returns true assuming the user has been authenticated.
(The body of the main script which called this function is as follows:
if($submit)
{
authenticate_user($username, $password)
echo $uid;
} )
I am trying to echo out the $uid session variable - but it appears to
be empty. I have even tried setting a "global $uid;" at the top of the
body as well as within the html head but to no avail. Can anyone spot
why my $uid session variable is returning blank although it is
definitely being set within my authenticate_user(..) function?
Many thanks in advance for all your help!
Dipen