simultaneous access lock - Codeigniter

Asked

Viewed 362 times

0

I need to block Simultaneos accesses with the same login on my system, currently using Codeigniter as framework.

When logging into the system, I can set 'logged in' in the BD and the logout is released access to that user.

Issues: When closing the browser or terminating the session, the release routine is not performed.

1 answer

0

I’ve had this problem and found some tips, but no effect, as the Jquery $(window).unload(function(), but none of it had any effect.

The best I’ve seen that you can do is:

1- you save in the database the date and time that the user logged in each login;

2- create a function that on every visited page is updating every x minutes, that login time; (you can call this function in the __construct of each controller)

3- create a event in your database, run a select every "y" minutes checking whether the date recorded in the database is less than 5 minutes for example, according to the time you set to last its session. (observing if it is a site with many simultaneous accesses, probably not a good idea, maybe it needs to be a dedicated server, because the bank event is running in infinite loop, so that it works)

Because if the user closes the page unintentionally and wants to go back to where he was, he will be able to do so without having to log in again due to the active session. And if it happens to actually close the page without logging out then you set to 1 minute after the session time expires, be the maximum time difference of the server’s current time, with what is in the database.

Example, session set to 10 minutes, vc sets the time to check in select between 11 or 12 minutes.

I hope I helped. Good luck.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.