views:

584

answers:

2

How do I implement a "Remember Me" function in Grails so that the user can check it and he won't have to log in again for 2 weeks?

I'm using the jSecurity plugin and want to change the cookie's lifetime beyond the browser session.

+4  A: 

JSecurity already supports RememberMe functionality. Take a look at the AuthorizationController, you'll find that it supports parameter "rememberMe."

To implement a two-week time-out, I'd add another cookie and modify AuthorizationController to behave accordingly. There may be that functionality in JSecurity, not sure about that - doesn't seem the controller respects it.

Jean Barmash
+3  A: 

Spring security (formerly acegi security) has this built-in, if you can use that plugin.

otherwise, the other posted solutions work nicely.

Chii