Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure a session timeout for Grails application?

In one of controllers in my Grails application I'm preserving a parameter value in a session variable like this:

session.myVariable = params.myValue 

After that, I can access the saved value from different controllers/GSP-pages as long as I actively use the app. However, if I don't use my app for a while, even though my browser window is still open, the session variable looses it's value.

Does this happens because the session expires? I was under impression that a session lives until the browser window is still open, but apparently I was wrong.

What should I do to ensure all session variables I define in my Grails app don't expire until the browser is closed? Is there any way to set session timeout manually?

Thank you in advance for your answers!

like image 460
curd0 Avatar asked May 25 '10 18:05

curd0


People also ask

How many ways are there to configure session timeout in your application?

There are two ways to set session timeout for a Java web application: using XML or Java code.

How do I manage session timeout?

Click Servers > Server Type > WebSphere Application Servers > WebSphere Portal. Click Container Settings > Session management > Set Timeout. Enter the desired timeout value in minutes. Click OK.

What is application session timeout?

Session timeout represents the event occuring when a user does not perform any action on a web site during an interval (defined by a web server). The event, on the server side, changes the status of the user session to 'invalid' (ie.


1 Answers

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.

like image 149
Stefan Armbruster Avatar answered Sep 21 '22 12:09

Stefan Armbruster