MrFish Posted June 30, 2009 Share Posted June 30, 2009 I'm using ajax to check if a username/password match exists for the username/password typed in. The problem is, it won't stick. When you login, if it is successful, this code runs and the div that holds the forms takes on the echo value. And it works correctly. But when you refresh the cookie no longer exists. Why is this? Is there a problem with my $time? $time = time()+60*60*24*365;setcookie("username", $username, $time);echo "You're logged in, <b>" . $_COOKIE["username"] . "</b>."; Link to comment Share on other sites More sharing options...
justsomeguy Posted June 30, 2009 Share Posted June 30, 2009 No, there's not a problem with the time. After you run the code and set the cookie check in the browser's list of cookies to see if it was actually created.Additionally, cookies are not a good way to keep track of who is logged in, at least not without some sort of encryption or protection. It's easy enough to make any cookie you want, so I can create a cookie for your domain called "username" with the name "admin" and, if you don't take any other precautions, you'll assume I'm logged in as admin. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.