getting and setting cookie spring mvc

Asked by
I am using @requestbody and @responsebody annotations for my authentication method using Spring MVC. I want to know how can I get and set cookies in spring mvc.. I need to store username and password in my cookie, which I am getting through the requestbody. Also want to know how can I get this set cookie in the browser, the next time the user logs in. Also does the browser sends the cookie automatically with the request body ? To be specific I don't want to go for Spring Security Remember me option. I am new to spring framework so an example code would be highly appreciated.

Best Answer

Answer by
Never store passwords (even encrypted) in Cookies. To implement the Remember me functionality you desire, you follow this http://stackoverflow.com/a/12990591/960778

To write a value to cookie in spring, refer this: http://stackoverflow.com/questions/4888456/in-spring-mvc-3-how-to-write-a-cookie-while-returning-a-modelandview

Your Answer

Name:
Answer: