package com.ns.mobile.website.config; import javax.servlet.http.HttpSessionAttributeListener; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import lombok.extern.slf4j.Slf4j; @Slf4j @Configuration public class HttpSessionConfiguration { @Bean public HttpSessionListener httpSessionListener() { return new HttpSessionListener() { @Override public void sessionCreated(HttpSessionEvent sessionEvent) { log.info("세션 생성, Session ID: {}", sessionEvent.getSession().getId()); } @Override public void sessionDestroyed(HttpSessionEvent sessionEvent) { log.info("세션 소멸, Session ID: {}", sessionEvent.getSession().getId()); } }; } @Bean public HttpSessionAttributeListener httpSessionAttributeListener() { return new HttpSessionAttributeListener() { @Override public void attributeAdded(HttpSessionBindingEvent se) { // This method will be automatically called when session attribute added log.info("Attribute Added following information"); log.info("Attribute Name:" + se.getName()); log.info("Attribute Value:" + se.getName()); } @Override public void attributeRemoved(HttpSessionBindingEvent se) { // This method will be automatically called when session attribute removed log.info("attributeRemoved"); } @Override public void attributeReplaced(HttpSessionBindingEvent se) { // This method will be automatically called when session attribute replace log.info("Attribute Replaced following information"); log.info("Attribute Name:" + se.getName()); log.info("Attribute Old Value:" + se.getValue()); } }; } }