marklarah Posted May 8, 2008 Share Posted May 8, 2008 Okay, so im making a simple login system, and im using cookies. When I was just testing, my login.php was just setting a cookie, with the value of 123, but with my login system, each user has their own unique key, and then data is checked against that in the lookup. It worked in testing the cookie, and my main page recognized it had been set, but now in my login page, it doens't. I had trouble with headers, and so the ob_start() is in db.php (an include, at the bottom of that page) Previous, I didn't buffer it, but now i have to. So, this is my problem - it shows no errors, but seems to not set the cookie. My login code: <? include 'db.php'; ?> <html><title>Space Battle :: Login</title> <body bgcolor="black" text="#fff"> <h3>Login</h3><br> <? if (!isset($_POST['user'])){ ?> <table width="500"><form action="" method="post"> <tr><td width="130"> Username:<br> Password: </td><td width="300"> <input type="text" maxlength="50" name="user"><br> <input type="password" maxlength="50" name="pass"> </td></tr></table> <br> <input type="submit" value="Go!"></form> <? }else{ $name = htmlentities($_POST['user']); $pass = md5($_POST['pass']); $result = mysql_query("SELECT * FROM `Players` WHERE `name` = '$name' AND `password` = '$pass'"); $num = mysql_num_rows($result); if ($num == 1){ $row = mysql_fetch_array($result); $key = $row['s_key']; setcookie("login", $key, time()+(60*60*24*365)); ob_end_flush(); }else{ $fail = "<br><b><i><font color=\"red\">FISSION MAILED: Try Again</font></i></b>"; } if (isset($fail)){ echo $fail; }else{ echo "<br>Login Successful. Redirecting now."; ?> <meta http-equiv="REFRESH" content="2;url=index.php"></HEAD> <? } } ?> ??? Ps, i know its not indented, im using a web editor. Sorry. Quote Link to comment https://forums.phpfreaks.com/topic/104753-solved-cookies-and-such/ Share on other sites More sharing options...
marklarah Posted May 8, 2008 Author Share Posted May 8, 2008 never mind I fixed it. Quote Link to comment https://forums.phpfreaks.com/topic/104753-solved-cookies-and-such/#findComment-536237 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.