Spring/Spring MVC
[Spring MVC] 로그인 처리 - 쿠키, 세션
잉숭
2021. 7. 20. 13:14
v1
SessionManager 객체 사용
로그인 : SessionManager 클래스 객체를 생성하여 세션 생성하여 저장하고 쿠키 전달
sessionManager.createSession(loginMember, response);
로그아웃 : 세션저장소에서 세션 삭제
sessionManager.expire(request);
v2
HttpSession 객체 사용
로그인 : HttpSession 객체를 생성하여 세션 저장하고 쿠키 전달
HttpSession session = request.getSession();
session.setAttribute(SessionConst.LOGIN_MEMBER, loginMember);
로그아웃 : 세션 삭제
session.invalidate();
v3
@SessionAttribute 어노테이션 사용
로그인 :
session = request.getSession()
session.setAttribute(SessionConst.LOGIN_MEMEBER, loginMember)
로그아웃 :
session.invalidate()