Reputation: 2266
I was following below tutorial for Spring Boot Login example with Spring Security example:
I am able to build the web application. Security is working fine.
Now the next part is to manage the session. I want to store user data, roles and some other details in session. How to do this ?
Upvotes: 0
Views: 12359
Reputation: 665
As already stated, spring manages the session for you. It stores the user data, roles etc. for you. If you want to check that just Add the Principal as one your argument in your controller class. which is the currently logged in security user, for example:
@RequestMapping(value = {"/", "/welcome"}, method = RequestMethod.GET)
public String welcome(Model model, Principal principal) {
System.out.println(principal.getName());
return "welcome";
}
Altough if you want to refine this strategy and add your own logic, just follow this tutorial: http://www.baeldung.com/spring-security-session
Upvotes: 3