세션 타임아웃 시 세션정보 제거하는 클래스 추가
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.eactive.eai.rms.common.login;
|
||||
|
||||
import javax.servlet.annotation.WebListener;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@WebListener
|
||||
public class SessionDestructionListener implements HttpSessionListener {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SessionDestructionListener.class);
|
||||
|
||||
@Override
|
||||
public void sessionCreated(HttpSessionEvent se) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 세션 타임아웃 등으로 소멸 시 세션정보 삭제
|
||||
*/
|
||||
@Override
|
||||
public void sessionDestroyed(HttpSessionEvent se) {
|
||||
|
||||
try {
|
||||
HttpSession session = se.getSession();
|
||||
|
||||
String userId = (String) session.getAttribute("userId");
|
||||
|
||||
// 로그인 한 사용자의 세션정보 정리
|
||||
if (userId != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("[SessionListener] 세션만료 감지. 사용자 제거: " + userId);
|
||||
}
|
||||
|
||||
SessionManager.removeUserSession(userId);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
logger.error("[SessionListener] 세션 정리 중 오류 발생", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user