How to store variable in session codeigniter

前端 未结 4 903
情歌与酒
情歌与酒 2021-01-05 17:10

I would like to store the variable in the session currently i am tryin like this but not working.

In Controller



        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-05 17:47

    You don't have to set the session the PHP way.

    CodeIgnter has its on Session Class

    Load the session library:

    $this->load->library('session');
    

    To set session data:

    $this->session->set_userdata('some_name', 'some_value');
    

    To retrieve session data:

    $this->session->userdata('some_name');
    

    To remove session data:

    $this->session->unset_userdata('some_name');
    

提交回复
热议问题