Reputation: 1064
For the following scenario where a user logs into my application and closes the browser and then restarts browser after some time and hit my application url then the user should get logged in automatically.
for this scenario my friend suggested to try to use spring Remember-me feature. while i was trying to understand spring remember me concepts, in every example a check box is used. Can i implement it without checkbox? Or this is a wrong approach?
Upvotes: 0
Views: 373
Reputation: 5035
You can easily implement is without a checkbox, but this is generally not a good idea if the site is publicly available on the internet. Imagine a user goes to the library and logs into your site, unless he remembers to click logout, the next user will automatically be logged in as the previous user (and most users just close the browser to log out).
When you post the login page, the remember-me checkbox is sent along as a normal post key-value pair. So if you always want remember-me, you can simply create a hidden field, with the value the checkbox would have when checked.
<input name="remember-me" type="hidden" value="on">
Upvotes: 1