user1123530
user1123530

Reputation: 561

Saving session data before session timeout?

Basically what I'd like to do is to instruct my application to write the session data to a MySQL database before timing out and deleting it from memory.

For example, say I have a User bean that contains the user's name, and I'll be changing that name a lot so storing it to the database every time a change occurs isn't an option, I want to be able to make the changes on RAM. The, when time comes and the user goes inactive, just before unloading it all I want to save it to my database.

Upvotes: 0

Views: 718

Answers (1)

Pradeep Pati
Pradeep Pati

Reputation: 5919

You need to implement a listener, HttpSessionListener to be specific. it will give you a callback method called sessionDestroyed(HttpSessionEvent hse), which you can use to implement your session data saving logic.

Upvotes: 1

Related Questions