CodeIgniter Forums
prevents login with same username at the same time - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: prevents login with same username at the same time (/showthread.php?tid=31959)



prevents login with same username at the same time - El Forum - 07-08-2010

[eluser]dpsamarasekara[/eluser]
hi,

i'm doing a site and i need to prevents login with same username at the same time.but there are several other modules bind to main system and they have own codeigniter installations. but loggin is centralized.so same user can't log in two places using his username. if so i need to give msg "username is in use" .

how can i do this.


prevents login with same username at the same time - El Forum - 07-08-2010

[eluser]toolwieldingape[/eluser]
You could add the user_id to the session table and kick out the old session if one exists.

should work.


prevents login with same username at the same time - El Forum - 07-08-2010

[eluser]WanWizard[/eluser]
That's basically how I have implemented it.

In my case the user_id is part of the session data, so I use a regex to check if a session record for that user exists.


prevents login with same username at the same time - El Forum - 07-08-2010

[eluser]dpsamarasekara[/eluser]
hi thank you for both of you. is session table automatically delete a recode once one have left or do i need to do it manually. i means if the use left the browser with out logging of or if he had a power cut. then session table keeps the recode and user can't log in again. i don't know how the process going, but if so it'll be a problem.

what do you think?

thank you.

Dinesh


prevents login with same username at the same time - El Forum - 07-09-2010

[eluser]shower[/eluser]
to avoid such conditions you can do

1.add the users to the dictinary in session start( of course you need to check whether the user already exists or not)


2.if the users exist do allow to proceed

3.Remove the users from the section once the user logouts out

4. create a dictionary in application start event


prevents login with same username at the same time - El Forum - 07-09-2010

[eluser]dpsamarasekara[/eluser]
hi,

thank you for replying but i didn't get what did you mean by "dictionary".

and it's not clear me the procedure as well.is that a another table? i can't understand that.please say it again with more details.

thank you very much for guiding me.