Hi
I have a log in script that if successful starts a session. When you enter the correct info it days that you are logged in, but when you try to acces a restricted file it says that you are not logged in. If you then log in again it works fine. I am not sure even where to start looking for the problem, is it likely to be in the log in script or in the restricted file?
I start the session at the top of each page so I don't think that is the issue, here is the part of my script that i think is most likely the cause of the problem, if anyone could have a look I'd be very grateful.
$sql="SELECT `active` FROM `users` WHERE `username`='".$username."' AND `password`='".$realp."'"; $search = mysql_query($sql) or die(mysql_error());
$match = mysql_num_rows($search);
if($match==1)
{
$_SESSION['authenticated'] = true ;
$_SESSION['username']=$_POST['username'];
$_SESSION['password']=$_POST['password'];
$url = 'index.php'; // default page for
if(isset($_SESSION['url']))
{
$url = strip_tags($_SESSION['url']);
unset($_SESSION['url']);
}
header("Location: http://website.com/$url");
exit("<p>Authenticated variable is: " . $_SESSION['authenticated'] . "</p>");
}
Thanks
Gilgil