How to configure a session timeout for Grails application?
Solution 1:
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:
<session-config>
<session-timeout>60</session-timeout>
</session-config>
The value of session-timeout uses minutes as unit.
Solution 2:
Fast forward a few years... For Grails 3.0 set the session timeout with ServerProperties in the application configuration file.
grails-app/conf/application.yml
server:
session:
timeout: 3600 #seconds
Default value: 1800 seconds (30 minutes)
Verify the timeout for the HttpSession from a controller using
getMaxInactiveInterval()
:
log.println "Timeout: ${session.getMaxInactiveInterval()} seconds"
Output --> Timeout: 3600 seconds
Update: Edited configuration for changes in Grails 3.1