scibby Posted December 17, 2010 Share Posted December 17, 2010 Heyyy, First time poster long time readerr I have a problem with my login system that i'm currently creating for a game. I've never been good with cookies so was hoping to grab some advice on this problem and anything to make my system work better with cookies . login.php ----------------------------------------- <?php ob_start(); if(isset($_COOKIE['id']) && isset($_COOKIE['password'])) { echo(" <br /> - <font color='#dddddd'>Welcome $username!</font><br /> - <a href='?x=bank'>Bank</a><br /> - <a href='?x=levelup'>Level Up</a><br /> - <a href='?x=members&r=edit'>Edit Profile</a><br /> - <a href='?x=members'>Member List</a><br /> - <a href='?x=logout'>Logout</a><br /> <br /> "); if($_POST['login']) { $username = safe($_POST['username']); $password = safe(md5($_POST['password'])); $check = mysql_query("SELECT * FROM `users` WHERE username='$username'") or die(mysql_error()); $info = mysql_fetch_array($check) or die(mysql_error()); if(mysql_num_rows($check) == 1 && $pass == $info['password']) { setcookie(id, $info['id'], time() + 3600, "/"); setcookie(password, $password, time() + 3600, "/"); echo("<meta http-equiv='refresh' content='4;url=http://www.simplydollclothes.com/matty/index.php'>"); echo("You have successfully logged in!"); } } else { echo(" <form name='login' method='POST'> <table width='100%'> <tr> <td width='25%'><font color='#dddddd'>Username</font></td> <td width='75%'><input type='text' name='username' size='17' /></td> </tr> <tr> <td width='25%'><font color='#dddddd'>Password</font></td> <td width='75%'><input type='password' name='password' size='17' /></td> </tr> <tr> <td width='25%'><input type='submit' name='login' value='Login' /></td> <td width='75%'><a href='?x=forgotpass'>Forgot password?</a> <a href='?x=register'>Register</a></td> </tr> </table> </form> "); } } ?> After pressing login the page just refreshes lightning fast and no cookies are set. Any help will be much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/221939-login-system-not-recording-cookies/ Share on other sites More sharing options...
mac007 Posted December 17, 2010 Share Posted December 17, 2010 hi, there... I'm a newbie myself.. but just wanted to comment that most often I find SESSIONS being used most commonly to track users, specially as it refers to login kind of stuff. Maybe you might want to look into that too... Quote Link to comment https://forums.phpfreaks.com/topic/221939-login-system-not-recording-cookies/#findComment-1148515 Share on other sites More sharing options...
scibby Posted December 17, 2010 Author Share Posted December 17, 2010 Thanks for the quick reply but I want to use cookies for this and extend on the security measures. I've used sessions before and its much easier Quote Link to comment https://forums.phpfreaks.com/topic/221939-login-system-not-recording-cookies/#findComment-1148526 Share on other sites More sharing options...
scibby Posted December 17, 2010 Author Share Posted December 17, 2010 solved =] Quote Link to comment https://forums.phpfreaks.com/topic/221939-login-system-not-recording-cookies/#findComment-1148547 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.