package com.style24.core.support.session;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import lombok.extern.slf4j.Slf4j;

import com.gagaframework.web.security.GagaSession;

/**
 * Session
 * 
 * @author gagamel
 * @since 2020. 10. 5
 */
@Slf4j
public class TscSession extends GagaSession {

	/**
	 * 세션 설정
	 * @param name - 명칭
	 * @param value - 값
	 * @return HttpServletResponse
	 */
	public static void setAttribute(String name, String value) {
		HttpServletRequest request = getHttpServletRequest();
		request.getSession(true).setAttribute(name, value);
	}

	/**
	 * 세션 값 조회
	 * @return 세션 값
	 */
	public static String getAttribute(String name) {
		HttpServletRequest request = getHttpServletRequest();
		HttpSession session = request.getSession(true);

		if (session != null && session.getAttribute(name) != null) {
			return (String)session.getAttribute(name);
		}

		return "";
	}

}
