1

I have a login form and a processor in PHP. When I get all the code correct, my PHP still redirects back to the login form even when the cookie exists...

    <script >

  function redir2()


// Original JavaScript code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header. 
{
    function getCookie(user) {
        var re = new RegExp(name + "=([^;]+)");
        var value = re.exec(document.cookie);
        return (value != null) ? decodeURI(value[1]) : null;
    }
    // End of code by Chirp Internet, rest of code done by Joey's Place 
Productions, Ltd.
    document.write(getCookie("user")); // <--- For debugging so i can see if 
cookie('user') == Null || Value
    var cookie = getCookie("user");
    if (cookie == "" || "null") {
        window.location.href = "/a.html";
    } else {}
} 
   </script>

<?php
 if(isset($_cookie['user'])) {
if($_COOKIE['user'] == '8877321829'){

    echo 'debug1' ; 
}
else{

  echo "<script> redir2(); </script>";
}
} else {

    echo "<script> redir2() </script>";
}

Could somebody tell me what i'm doing wrong and what needs fixing... Sorry about my weird indentation and code. I'm sort of a beginner as this is only my second post. If you need more info, i can give you the logon site's code as well

Joey M
  • 187
  • 1
  • 14

1 Answers1

0

$_cookie should be caps. Change it to $_COOKIE and it should work.

Aniket G
  • 3,471
  • 1
  • 13
  • 39