PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$user = $_COOKIE['user'];
if (!isset($_COOKIE["user"]))
die('<font color="red"><b><big>Error:</big></b></font><font color="black"><br><br>You must log in first! Click <a href="http://www.monbre.com">here</a> to go back to the homepage, and either signup or login.</font>');
$scookie = mysql_query("SELECT * FROM user WHERE securecookie = $user");
if ($user != $scookie)
die("Hmm. That's weird! It's almost as if you were TRYING to edit the cookie data to your advantage. Huh, silly goose.");
Okay, now. The cookie is set to 'encrypt' (I just used rand()) the username. Meaning, they log in, and then in the database entry "securecookie", it takes the rand() number I gave them for the cookie session, and puts it in there. Then I set $scookie to be equal to me going to the database entry "secure cookie", and searching for anyone with the cookie's value in there. It should only find one; if it finds two, I'll fix that later. But for now anyway, it's not working. It just says that everyone is trying to edit the cookie data. =/
$user = $_COOKIE['user'];
if (!isset($_COOKIE["user"]))
die('<font color="red"><b><big>Error:</big></b></font><font color="black"><br><br>You must log in first! Click <a href="http://www.monbre.com">here</a> to go back to the homepage, and either signup or login.</font>');
$scookie = mysql_query("SELECT * FROM user WHERE securecookie = $user");
$scookie = mysql_fetch_array($scookie);
$scookie = $scookie['fieldofcode']; // you need to tell php which field the data is in
if ($user != $scookie)
die("Hmm. That's weird! It's almost as if you were TRYING to edit the cookie data to your advantage. Huh, silly goose.");
Last edited by tecktalkcm0391 on Sun Feb 04, 2007 2:05 pm, edited 2 times in total.
I use cookies because I looked a 2 comparison articles, and it seemed like each style had its own flaws, and I'd rather deal with local flaws than server-side flaws.
Also, cookies are better for making games. Atleast, that's what one of the articles said. (not games exactly, though)
Maybe it's the fact I'm stressed from the super bowl party. But what is wrong with this? >_> It looks exactly like the code above. Yes, that did indeed work, but now I'm trying to get their username from the table "user", where it is defined by their random code.