Codeigniter会话ID在帖子上删除

时间:2016-04-11 00:31:17

标签: php codeigniter session post

每次我注册或删除用户(做任何涉及帖子的事情)我的Codeigniter会话用户ID被删除。我正在使用codeigniter 3.0.6

这是我的会话config.php: $config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_save_path'] = sys_get_temp_dir(); $config['sess_match_ip'] = FALSE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = FALSE;

  `$config['cookie_prefix'] = '';
   $config['cookie_domain'] = 'localhost'; //this used to be mysite.space
   $config['cookie_path']       = '/';
   $config['cookie_secure'] = FALSE;
   $config['cookie_httponly']   = FALSE;`

您可以在下面看到之前和之后:

After login I set this->session->userdata in the model

after post and return to dashboard

会话ID到达控制器但在控制器和模型之间丢失/消失。当DB发布/删除操作发生时,我将此 - > load->视图重定向回仪表板,会话ID消失。 请帮忙!

我在模型中设置会话userdata。我正在$ autoload ['libraries'] autoload.php

中加载会话

继承人我的控制人员:

      `public function login()
    {
        if($this->User->login($this->input->post())){
        $my_trips = $this->User->get_my_trips();
        $userp = $this->User->get_dash_user_info();
        $this->load->view('/dashboard', array("user"=>$userp,                  

    'my_trips'=>$my_trips));
       } else {
          redirect('/');
       }
    }`

Heres模型:      $this->form_validation->set_rules("username", "Username", "trim|required"); $this->form_validation->set_rules("password", "Password", "trim|required"); // END VALIDATION RULES if($this->form_validation->run() === FALSE) { $this->session->set_flashdata("errors", validation_errors()); return FALSE; } else { $query = "SELECT * FROM users WHERE username = ? AND password = ?"; $values = array($post['username'], $post['password']); $user = $this->db->query($query, $values)->row_array(); if(empty($user)) { $this->session->set_flashdata('errors', '<p id='error'>The username or password you entered is invalid.</p>'); return FALSE; } else { $this->session->set_userdata('id', $user['id']); return TRUE; }

0 个答案:

没有答案