Calling custom method before session auto destroy

Is there any way to call a custom method before session gets auto/mannual destroyed?

My problem is, I am capturing user logout time in the DB. Its working fine when user gets logout manually (By calling logout method) but I am not able to capture logout time when user's session gets auto destroyed after timeout.

Appreciate suggestions on this.


Yes it is possible. See this website for a in-depth tutorial Using session_set_save_handler() (PHP doc) you can add your own function for the GC (garbage collection) cycle. That way you can tell which sessions are about to be destroyed by that garbage collection cycle, and manually update those records in the database with the current timestamp.

If you then end your function by calling the default GC handler you've basically inserted your own bit of logic in between.

In php you can implement SessionHandlerInterface and use your custom code on destroy() or gc() (see comments), more info here -

In YII you can setup a custom session handler.

Need Your Help

Python Uno Not Found On Latest Open Office Installation

python import uno pyuno

Am now on the third Open Office 4 installation this week, direct from their site, ensuring 'Python Uno' is selected. Whether running

How can I collapse a dataframe by some variables, taking mean across others

r ggplot2 pivot-table

I need to summarize a data frame by some variables, ignoring the others. This is sometimes referred to as collapsing. E.g. if I have a dataframe like this: