What is it you're trying to do exactly? Please provide more details.
Trigger code execution when session expires
Is it possible to trigger the execution of code when a session expires?
Other platforms have a way to execute code when a session ends. For example, ASP.net has a 'Global.asax' file with a function call 'Session_End()' where you can add code that it is executed every time a session ends. Is there anything similar in Laravel?
By 'session' do you mean a user logs out (or times out) - or the end of the current code run from a request?
I mean that session times out. If a user logs out I can execute code when he/she logs out. That would be part of the request cycle. What I am asking is about the possibility of execution of code when a session times out, when there is no user intervention.
You could look into http://laravel.com/docs/5.1/session#adding-custom-session-drivers - I think the gc method would let you do some custom stuff from a quick look at https://github.com/laravel/framework/blob/5.1/src/Illuminate/Session/Middleware/StartSession.php#L142 .
Thanks 'ohffs', I am going to have a look at it. I'll give feedback.
Why do you want to do this ?
@LunaLlena looks like you could extend one of the laravel session drivers and just over-ride the gc method - for instance the default file driver looks fairly straightforward to add code inside the foreach loop : https://github.com/laravel/framework/blob/5.1/src/Illuminate/Session/FileSessionHandler.php#L85
Alternatively, just before the session ends you could popup a "Session will expire in 'n' seconds" reminder and if no action is taken - do your stuff.
Whether this worked or not? @LunaLlena @ohffs @sitesense Even i want to do the same in Laravel 5.4
Please or to participate in this conversation.