0
votes

Currently I have an issue with CodeIgniter and sess_destroy, I want to have a user to have only one session, so I'm validating if the user have a previous session and he/she want to continue on this second session, we call an exit function to kill the first session so the user can keep the second session he/she starts.

This is my function to destroy the session:

public function salteya(){
      $this->session->set_userdata(array());
      $this->session->sess_destroy();
      log_message('error', "salteya");
      //redirect(base_url("Administrador/gotohome"));
    }

The behavior is that when the user starts the second session and I try to destroy the first session need to refresh two times the pages or change the page two times to destroy the session.

Anyone had this issue before? Undecided

Best regards,

1
do you have a login form for it?curiosity
yes i have it, it create a session without any issues, and logout with the button well, but once I've tried to kill second session from server it needs two refresh or navegations to fully kill the session.Claudio Rivas
what does second and first session actually mean ? a user only have one session at a time - so if you want to destroy current session you dont have the second one and vice versa.sintakonte

1 Answers

0
votes

try this

public function salteya(){
      $this->session->unset_userdata();
      $this->session->sess_destroy();
      log_message('error', "salteya");
      //redirect(base_url("Administrador/gotohome"));
    }