Session in Spring Loading Application
Like others have suggested, you can use Spring security. Or, if you don't want to deal with the intricacies of Spring Security, you can get the object HttpSession
in the arguments of the controller handler methods. You can set values ββor objects in this session using HttpSession.setAttribute("name you want to refer to", actual value or object)
after user login. And when the user clicks on logout, you can use HttpSession.invalidate();
to log out.
source to share
The best solution for this would be using Spring Security. Take a look at this: https://spring.io/guides/gs/securing-web/ .
source to share
It is recommended to use Spring Security.
You can find many examples if you are looking for "spring security tutorial" on google.
For example, this is the official tutorial with angular js (1.x) https://spring.io/guides/tutorials/spring-security-and-angular-js/
If you don't want to use Spring security, you need to create an http session and store the logged in user data in the http session.
In Spring, you can inject HttpSession to your bean and you can add session attributes, or you can create a session bean application.
source to share
Spring Security is the best option for authentication and authorization. To log in, if a new user has registered, you need to save the session for a specific user before logging out. You can use Spring Security Session Management.
http://www.baeldung.com/spring-security-session
You can set the UserDetails object to http.setAttribute ("USER_DETAILS", userDetails);
(userDetails is a UserDetails object that is in the constructed class)
You can use this httpSession object, for example httpSession.getAttribute ("USER_DETAILS"); for further manipulation. To log out, use can use the httpSession.invalidate () method.
source to share