I have written a function to remember the user that has just logged in. It looks to me that it should work, but no Idea why it doesn't work. The problem is that the cookie doesn't get made when I look into my browser's stored cookies.
This is the function I'm talking about:
function rememberUser($id) {
$mysqli = new mysqli('bla', 'blabla', 'blablablaa', 'blaaaaa');
if(mysqli_connect_errno()) {
echo "Connection Failed: " . mysqli_connect_errno();
exit();
}
$remember = md5(uniqid(mt_rand(),true));
$stmt = $mysqli->prepare("UPDATE USERS SET USER_REMEMBER_KEY = ? WHERE USER_ID = ?");
$stmt->bind_param('si', $remember, $id);
$stmt->execute();
setcookie("remember", $remember, time()+60*60*24*30, "/", "www.someSite.com", false, true);
}
I should mention that the query works fine and USER_REMEMBER_KEY
is stored fine in the DB. So the problem is really the cookie, I think.
Does anyone see the problem here? Thanks in advance.
UPDATE: I'm using Google Chrome BETA version 19.xx
No comments:
Post a Comment