0

I develop a registration system using codeigniter. I don't want the user to have multiple session active. ie user login with a username and password on chrome browser and now goes to firefox and login with the same username and password.

//I added a column calld userid
ci_sessions // codeigniter session database

//check whether a session exist and delete
$this->db->delete('ci_sessions',array('userid' => $this->input->post('reg_nos')));

//create a session data
$this->session->set_userdata(array('reg_nos'=>$this->input->post('reg_nos')));

//get the current session and update it with the userid value.
$session_id = $this->session->userdata('session_id');
$this->db->where('session_id', $session_id);
$this->db->update('ci_sessions', array('userid' => $this->input->post(reg_nos')))

Is there a better to implement this? I can't even get it to work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
EBIWARI
  • 43
  • 1
  • 6
  • What have you tried? What errors are you receiving? This is not a code request site, it is a code question and answer site, nobody is going to code your solutions for you – Lemuel Botha Oct 09 '14 at 08:09
  • share your Login Code & session driver info ??? – Saqueib Oct 09 '14 at 08:15

1 Answers1

0

I am not sure how you are handling logins, but if you are using cookies, store the cookie expiration date in the database and when a logs in you can check whether they have an active cookie or not. Expire the cookie on logout and also mark the cookie as inactive on the database. This will give you one session login control

Lemuel Botha
  • 659
  • 8
  • 22