security - Codeigniter and Multiple Concurrent Logins -


i come security background infosec consultant , tested webapps vulnerabilities. i've started working webdev , i'm busy first project, written codeigniter.

i'm trying solve problem of multiple concurrent logins, user can have 2 (or more) concurrent sessions both valid , active. have idea how i'm not experienced ci want know if there's better or more "official" way. involves making changes db's ci_sessions table, not sure how ci handle it.

at moment i'm using db session data, plan add additional coloum ci_sessions table, 1 stores email address of user (post authentication). in other words null until user logs in, @ point email address of user stored in it.

the plan confirm validity of credentials provided during login , if they're correct search sessions table other sessions corresponding same email address , delete those. once other sessions user have removed email , session data indicating valid authenticated session set.

is best way this?

edit: of course, won't work when ci creates new session id current session, instead of updating, ci won't set email address new session. i'd have make modifications source...

i looking through source code sessions.php , found line @ end of sess_update(), called if db sessions in use:

$this->ci->db->query($this->ci->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid))); 

in other words current session_id updated new session_id, instead of inserting new entry, leaving other information (except last_activity) intact. decided try original plan, added user_id column table (instead of email) defaults null. on login check credentials , return (amongst others) user_id of email address specified. delete sessions have specific id in user_id column , update line associated current session_id contain user_id of user.

i have tested logging in chrome , safari , chrome session killed. still need more testing ensure there no loopholes looks solves problem.

many suggestions. samutz, i'm sure method have worked, found mine had less overhead.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -