I dont understand wat has happened... the code was working fine yesterday when testing, and now i try to use it today, and it doesnt work.
setcookie() isnt setting the cookie... Maybe i have missed something, so hopefully someone here can see where ive gone wrong. Just to confirm though, this was working perfectly fine yesterday...and i hadnt made any changes to it since then so im really confuzzled. Any help will be appreciated..
www.mysite.com is just an example for posting here, it is replaced by the actual site address when testing it. I also understand the security issues in the code below, i dont need help with that, this is just for testing purposes... i just need to understand why setcookie isnt working. Thanks
<?php
include "include/config.php";
$_POST['password'] = addslashes($_POST['password']);
$user = addslashes($_POST['username']);
$password = md5($_POST['password']);
$userrow = mysql_query("SELECT * FROM users WHERE user_username = '".$user."' AND user_password = '".$password."' ");
ob_start();
if(mysql_num_rows($userrow) == "1"){
if (isset($_POST['rememberme'])) {
setcookie('username', $_POST['username'], time()+60*60*24*365, '/', 'www.mysite.com');
setcookie('password', md5($_POST['password']), time()+60*60*24*365, '/', 'www.mysite.com');
} else {
setcookie('username', $_POST['username'], false, '/', 'www.mysite.com');
setcookie('password', md5($_POST['password']), false, '/', 'www.mysite.com');
}
header('Location: index.php');
} else {
echo 'Username/Password Invalid';
}
ob_end_flush();
?>