Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shandur's avatar

How to invalidate particular session?

Hello. Stuck with a problem that I can't invalidate session for particular user. When user is logged in, I store session_id and user_id to the database. Then, when special event happens I want to invalidate particular users sessions. How can I do it properly? Thanks!

0 likes
3 replies
mikevrind's avatar

Which session driver are you using?

If you use de file driver, which is the default setting, you could probably remove the session file which hopefully has the same name as the session_id you stored in the DB..

striktly_romania's avatar

I just tried @mikevrind suggestion and found out that removing the file itself does not invalidate the session. I'm using the default setting with the file driver.

Please or to participate in this conversation.