Hi,

How would I check whether a customer is logged in to a website before proceeding if not then redirect them back to the current page?

So far I have tried using sessions to if the customer has logged in but it hasn't worked.

PHP Code:
     if ($_SESSION['username'] = $username && $_SESSION['upassword'] = $password){ 
echo 
"authenticated=true";
 
header("Location: displayProducts.php");
}else { 
//user doesn't exist
echo "authenticated=false";
 
header("Location: index.php");

The above code gives the following error:

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
* This problem can sometimes be caused by disabling or refusing to accept cookies.
What is the best if not the easiest way to do this?

Thanks,


Nightwalker