Welcome Guest, Not a member yet? Register   Sign In
Logout Session with sess_destroy() not working
#1
Sad 

Hello Devs,

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,
Reply
#2

Try to delete your session before redirect to another page
Reply
#3

(This post was last modified: 01-20-2020, 01:39 PM by jreklund.)

How are you storing your sessions? File? Database?
Do you store a userid alongside the session id? (in the database)

If you do just delete all old sessions in the database and every request a user makes to your site will look if there an active session in the database. If it dosen't redirect them to your login.

But this idea are a really bad user experience. Nowadays people have PC, Laptops, Cellphones and Tables. All logged into the same account. And now you are forcing them to log in every time. If this is a billing issue, you should start tracking them another way (user uses both devices at the same time). And bill them accordingly.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB