My login check, whats wrong!!

Can anyone see whats wrong with this?
Its meant to check if your logged in by checking if the session and the cookie are the same (my login method).
Whats wrong:


if($_SESSION[‘username’] = $_COOKIE[‘cookname’]); {
echo (’

} Else {
echo “Please Login!”;


All Reply s and help will be greatly appreciated.
Team Storm

if($_SESSION[‘username’] = $_COOKIE[‘cookname’]); {

should be
if($_SESSION[‘username’] == $_COOKIE[‘cookname’]); {

= is the Assignment Operator

== is the Comparison Operator

In your statement
if($_SESSION[‘username’] = $_COOKIE[‘cookname’]); {
as long as the “ASSIGNMENT” of the value of $_COOKIE[‘cookname’] is made successfully into $_SESSION[‘username’] it will always return a TRUE. Only if the Assignment is NOT successful will it return a false.

Hope that makes sense.

Sponsor our Newsletter | Privacy Policy | Terms of Service