sessions don't expire in the way you might think. They are checked per request. If the user never comes back then the session is never checked. Each time a user visits there is a random chance that a session cleanup process runs. This just deletes old sessions from the system and could be days or weeks after your visitor left.
Session Listener
Hi there.
Is there a way to implement a listener for Session creation and Session destroy/expiration? I would like to add some attributes to the Session when it is created and remove some DB data on Session destroy/expiration, because I also want to insert the Session ID in some DB tables fields on creation.
If not, anyway to achieve that? I cannot find anything related in docs or even googling.
Thanks for your time.
Best regards, Diego.
@daglimioux You might want to look into laravel event/broadcasting system.
https://laravel.com/docs/5.4/events https://laravel.com/docs/5.4/broadcasting
I use a combination of Redis, broadcasting, socket.io to check for online users or users going offline. There is a ' connection' closed event when the user either logs out, closes the browser or gets idle.
https://laracasts.com/series/real-time-laravel-with-socket-io/episodes/4
Please or to participate in this conversation.