Welcome Guest, Not a member yet? Register   Sign In
Session Class -> sess_destroy not removing session
#7

[eluser]aplund[/eluser]
Hi all,

I also have problem with the sess_destroy. I have two controllers:

web_public
web_private

in the web_private controller I have the following function ran every time the controller is accessed.

Code:
public function is_logged_in()
        {
            //get state from stored cookie
            $is_logged_in = $this->session->userdata('is_logged_in');

            //if its not set and if not true, redirect to public pages
            if(!isset($is_logged_in) || $is_logged_in !== TRUE)
            {
                redirect('web_public/index');
                die();
            }
            
        }

My log in function (in the public controller)
Code:
public function do_login()
        {
            $data = array(
                   'username'       => 'aplund',
                   'is_logged_in'   => TRUE
               );

            $this->session->set_userdata($data);

            //redirect user to private controller
            redirect('web_private', 'refresh');
        }

My log out function (in the private controller)

Code:
public function do_logout()
        {
            //destroy session
            
            $this->session->unset_userdata('username');
            $this->session->unset_userdata('email');
            $this->session->unset_userdata('is_logged_in');
            
            $this->session->sess_destroy();
            
            //redirect user to public controller
            redirect('web_public/index');

        }

in the footer "session information" is:

Code:
<p>Username: &lt;?php echo $this->session->userdata('username'); ?&gt;</p>
  <p>is_logged_in: &lt;?php echo $this->session->userdata('is_logged_in'); ?&gt;</p>

Before I have logged in for the first time I can't reach the controller (as excpected) but as soon as I have logged in and out once I can reach the private controller. (Sometimes it redirect to the public controller as expected but its enough to refresh the page a couple of times and I can reach the private controller) It fells like my session is not destroyed properly?

you can try the site here to see the sites live.

Any ideas?


Messages In This Thread
Session Class -> sess_destroy not removing session - by El Forum - 10-25-2012, 12:35 PM
Session Class -> sess_destroy not removing session - by El Forum - 10-25-2012, 12:56 PM
Session Class -> sess_destroy not removing session - by El Forum - 10-25-2012, 01:07 PM
Session Class -> sess_destroy not removing session - by El Forum - 10-25-2012, 01:14 PM
Session Class -> sess_destroy not removing session - by El Forum - 10-31-2012, 08:03 AM
Session Class -> sess_destroy not removing session - by El Forum - 10-31-2012, 12:10 PM
Session Class -> sess_destroy not removing session - by El Forum - 06-10-2013, 06:06 AM
Session Class -> sess_destroy not removing session - by El Forum - 06-10-2013, 07:36 AM
Session Class -> sess_destroy not removing session - by El Forum - 06-12-2013, 09:42 AM
Session Class -> sess_destroy not removing session - by El Forum - 06-12-2013, 09:45 AM
Session Class -> sess_destroy not removing session - by El Forum - 06-12-2013, 10:59 AM
Session Class -> sess_destroy not removing session - by El Forum - 06-12-2013, 11:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB