Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine how to track httpsession destroy

anybody knows how to track httpsession destroy with GAE? I've found that HttpSessionListener doesn't work properly in GAE and sessionDestroyed method never calls.

To be more specific I have an information that I store in database when user logins to the application, but if some user is inactive for some time I need to remove this info from db, that will be easy if sessionDestroyed method will be invoked when such event happens, as for now I did cron job which runs each minute, the job queries all data of this kind handles in memory which data is inactive and removes it. But this is very inefficient way to do this, I can optimize it with cache. But maybe thare is some other elegant way.

Any thoughts are warmly appricated.

like image 692
endryha Avatar asked Jun 24 '26 06:06

endryha


1 Answers

As you observe, HttpSessionListener doesn't work on App Engine, so this isn't possible. This is in part due to the fact that App Engine apps run multiple instances on multiple machines, so there's no single VM to invoke this on. Running a regular cleanup script as you describe is the best way to do this, though there's really no reason to run it every minute - a couple of times a day should be perfectly sufficient!

like image 139
Nick Johnson Avatar answered Jun 25 '26 19:06

Nick Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!