开发者

Grails. Ways to set the timeout interval of a session. Which better?

开发者 https://www.devze.com 2023-01-28 12:06 出处:网络
I know two ways to set the timeout interval of a session: way 1: grails install-templates Then edit src/templates/war/web.xml

I know two ways to set the timeout interval of a session:

way 1:

grails install-templates

Then edit src/templates/war/web.xml

way 2:

write this line of code in your contr开发者_StackOverflow社区oller:

session.setMaxInactiveInterval(sec);

Which of these ways do you think is better - and why?


Changing the value in web.xml is best if you want a constant value for all sessions.

setMaxInactiveInterval is useful when you want to programmatically determine the current session's max length, but it's overkill to just set the value repeatedly to the same value.

0

精彩评论

暂无评论...
验证码 换一张
取 消