I have a login script in which i authenticate the user, and as soon as authentication is completed, i want to set cookies for him. but my script is executing perfectly till authentication, but it's not executing further after setcookie, may be it's not able to execute this function. Here is my code.
$validCredentials = checkCredentials($loginEmail, $loginPassword);
if ($validCredentials === 1)
{
if(isset($_POST['rememberMe']))
{
$yearExpire = time() + 60*60*24*365; // 1 Year
setcookie('rememberedUser', $loginEmail, $yearExpire);
setcookie('loggedIn', $loginEmail, $yearExpire);
}
else
{
if(isset($_COOKIE['rememberedUser']))
{
$pastExpire = time() - 100;
setcookie('rememberedUser', '', $pastExpire);
}
$shortExpire = time() + 60*60*24;
setcookie('loggedIn', $loginEmail, $shortExpire);
die(msg(0,"Logged In !"));
}
}
Please tell me whats wrong in my code. Please help !!