CodeIgniter Forums
Single User Access - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Single User Access (/thread-62339.html)



Single User Access - JoelPiccoli - 07-03-2015

Hello everyone! Everything allright?

I have a little big problem in my hands and I come here to ask you guys for help.  Huh

I develop a system for a client couple weeks ago. Yesterday he came with an ideia to implement the single user access, what means that a user can't be logged in two places at the same time.

I was wonderer if it could be implemented with the ci_sessions table in the database and if anyone here have already done something like this.


Thanks everyone!  Wink


PS: I forgot to tell that in this project I'm using CI 2 Wink


RE: Single User Access - skunkbad - 07-03-2015

Yes, and this is a feature of Community Auth. If you have a user and want to only allow one login, then when he/she logs in you store the session ID in that user's record. Every page load you see if the session ID matches the session ID in the user's record. If the session ID is updated in the session class, you update the session ID in the user's record. It's really pretty simple.


RE: Single User Access - JoelPiccoli - 07-03-2015

(07-03-2015, 10:18 AM)skunkbad Wrote: Yes, and this is a feature of Community Auth. If you have a user and want to only allow one login, then when he/she logs in you store the session ID in that user's record. Every page load you see if the session ID matches the session ID in the user's record. If the session ID is updated in the session class, you update the session ID in the user's record. It's really pretty simple.

Let me see if I understood, So, If I implement this my user will be unable to log with the same user in diferent places... Am I correct?


RE: Single User Access - skunkbad - 07-03-2015

Yes. Only one login per user, because there is only one session ID stored in the user's account, and it has to match for the user to be logged in. If the user logs in from a second device or location, then it will "kick off" the other session.


RE: Single User Access - Blair2004 - 07-05-2015

you can filter ip adresses and host device. don't forget to add a timeout in order to delete persistent connexion from one device...