douqi4673 2014-08-11 21:03
浏览 43
已采纳

CodeIgniter会话未设置

The session is not set in the following case. It was working for me earlier. I am using CodeIgniter.

 public function authenticate(){
    $user = new Entity\User;
    //$user2 = new Entity\User;
    $user->username = "prayag@gmail.com";
    $user->password = "prayag";
    $userRepository = $this->doctrine->em->getRepository('Entity\User');
    $checkLogin = $userRepository->checkLogin($user);
    echo "Username => ". $checkLogin[0]->username;
    echo "ID => ". $checkLogin[0]->id;
    $this->load->library('session');
    $this->session->sess_destroy();

    if(!empty($checkLogin)){
        $CI =& get_instance();
        $this->session->set_userdata('user_id',$checkLogin[0]->id);

        $loggedIn = $this->session->set_userdata('user_id');    
            if($loggedIn !== TRUE){
                echo "session is not set";
                //echo $this->session->set_userdata('user_id');
            } else {
                    echo "session is set";
            }
        }
        else{
            echo "Username not found";  
        }
    }

I tried to solve it using the following post: https://stackoverflow.com/questions/10712250/w hat-is-the-proper-way-to-test-codeigniter-session-variable

  • 写回答

3条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 在matlab中如何进行三个参数的离散傅里叶逆变换(idft)
      • ¥15 遇到问题了,求解答!
      • ¥15 请问coppliasim eduUR5视觉抓取怎么实现仿真,
      • ¥30 JavaWeb实验(购物平台)
      • ¥15 八路抢答器倒计时设计时显示器不输出,只能显示0
      • ¥15 用C语言随机生成一个迷宫
      • ¥15 超多因素的正交方案设计
      • ¥15 Scratch~汽车小游戏
      • ¥30 OSGB转换为3dtiles
      • ¥25 用于Audio的芯片中“Audio Interface”和“Mode Control”是什么?