Hey,
What I’m trying to do is a log in page with a session and cookies. The session part works fine but I just can’t get the cookies working.
How is the code below supposed to look? The cookie isn’t being set so I’m guessing that its running the query and immediately exiting and redirecting to the profile page. I find ifs and elses confusing, so any help is greatly appreciated.
Thanks,
Will.
[php] if(mysql_num_rows($result) == TRUE) {
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION[‘SESS_MEMBER_ID’] = $member[‘u_id’];
header(“location: member-index.php”);
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
if ((isset($_POST['remember'])) && ($_POST['remember'] == "yes"))
{
$cookie_name = "loggedin";
$cookie_value = $_SESSION['SESS_MEMBER_ID'];
$expiry = time() + 3600 * 24;
setcookie($cookie_name, $cookie_value, $expiry);
}
}[/php]