How to implement a mechanism to ban and delete a user session?

Arose the need to have for the admins the ability to ban user on the website.
He implemented the ban, but it is necessary that if there is a session (user is online) - she was purged or deleted immediately after pressing the button "ban", display the appropriate message.
The first thing that comes to mind, using the table of sessions on codeigniter - add a user_id field and let Ajax to check the status of the field if user_id exists, then the session alive, if no session->destroy().
Figured if so will check 10K users, for example, will be quite expensive.
Are there any other ways to implement open someone else's session without the constant reference in the database?
April 19th 20 at 12:05
2 answers
April 19th 20 at 12:07
Well I understand the ban is in some sort of users table field isBan = true?
Well, do to the user when loading any page checked this box, and if it is true, peel session, redirected where you want....
PS If unbearable, then Jaxom bullet every 10 seconds and if banned, then clean the session and give a beautiful pop-up
April 19th 20 at 12:09
Do not quite understand the application architecture. Like PHP and Ajax is assumed.

If you have PHP, you just need to reload the page each time to validate the user. Or if you want that already open page is closed? How much it matters in PHP. Let them look, next reboot and all the more no access. When you restart the message and to show that there is no access.
the point is that when the bath page the user is forcibly rebooted with the message that it was banned. - Kacey38 commented on April 19th 20 at 12:12
@Kacey38, Well, Ajax. But it is expensive. Such operation for a couple of users 10,000 users will send a request to the database every few seconds. Why? What happens if the banned user remains on the page until you reboot? If the page is static, neither of which he will get and if dynamic, to add a check in dynamics. - trent.Simonis commented on April 19th 20 at 12:15
@trent.Simonis, there is the idea after you click BAN, force the cache means the data framework and apply to a cache. - Kacey38 commented on April 19th 20 at 12:18
@Kacey38How to do it? How to get access to the Cache of the browser? - trent.Simonis commented on April 19th 20 at 12:21
@trent.Simonis, Yes, I agree, nonsense written. - Kacey38 commented on April 19th 20 at 12:24
decided to make 2 fields in the table sessions
user_id, is_ban
It is possible to index on the field user_id catch at is_ban. Work should be faster than the users table because users on the website < higher. users.

About instant gap session, decided to give up. - Kacey38 commented on April 19th 20 at 12:27

Find more questions by tags SessionsCodeIgniterPHP