Setting the timeout interval of a HttpSession
In my project, there was a requirement to set the session time out interval and i had no idea about how to implement it. Then my colleague Himanshu Seth came to rescue. This guy has already done it. All you have to do is to set the maximum time out interval in the session. Here is the sample code.
declare a SESSION_TIMEOUT constant in your application constants file (AppConstants.groovy).
public static final Integer SESSION_TIMEOUT = 3600 // This time is set in seconds. 3600 = 1 hour
Now set the maximum inactive interval of session. You need to write this line of code in your controller.
session.setMaxInactiveInterval(AppConstants.SESSION_TIMEOUT);
Hope it helps.
Another option would be modifying web.xml. Prior you must call
grails install-templates
Then edit src/templates/war/web.xml and add/modify after servlet-mapping:
60
The value of session-timeout uses minutes as unit.
isnt here a simple web configuration file where you can set the session timeout. why do it through code ?