Codeigniter session will not unset

◇◆丶佛笑我妖孽 提交于 2019-12-31 05:22:36

问题


im working on a community, and i want to user to log off but it dosent unset the userdata :S, do you know why?

this is my controller function

function logOff() {

        //$this->session->flashdata('reports', 'Du er logget af');

        //redirect('frontpage', 'refresh');
        $this->session->unset_userdata($sessionData);


    }

回答1:


You can destroy an entire session by calling the following:

$this->session->sess_destroy();



回答2:


You need to specify what elements you want to unset individually rather than a variable or object as per your code:

$this->session->unset_userdata($sessionData);

Instead use to remove the login information so you still preserve a basket or whatever else you have stored:

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

Or destroy the whole session:

$this->session->sess_destroy();  //as per Yorick's answer


来源:https://stackoverflow.com/questions/7866332/codeigniter-session-will-not-unset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!