dongtan6695 2013-02-12 05:49
浏览 52

php登录脚本中的setcookie无法正常工作

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 !!

  • 写回答

1条回答 默认 最新

  • dousiyou1058 2013-02-12 05:52
    关注

    you have written this line

    die(msg(0,"Logged In !"));
    

    and because of that it stops execution.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么