본문 바로가기
웹프로그래밍/JSP

쿠키 로그인여부

by 폴더맨 2024. 6. 8.

쿠키 로그인여부

<%@ page contentType="text/html; charset=EUC-KR" %>

<html>
<head>
<TITLE>로그인 확인 화면</TITLE>
</head>
<body>
<%
   Cookie[] cookies = request.getCookies();
   boolean isLogin = false;
   if(cookies != null && cookies.length > 0)
      for(int i = 0;i < cookies.length;i++) {
         String cookie_name = cookies[i].getName();
         String cookie_value = cookies[i].getValue();
         if(cookie_name.equals("ID") && cookie_value.equals("ADMIN")) {
            isLogin = true;
            break;
         }
      }
   if(isLogin) {
      out.print("<h2>로그인 한 상태입니다.</h2>");
   		out.print("<h3><a href=8-11.jsp>로그아웃</a></h3>");
   }
   else {
      out.print("<h2>로그인 안한 상태입니다.</h2>");
		out.print("<h3><a href=8-8.jsp>로그인</a></h3>");
   }
%>
</body>
</html>

'웹프로그래밍 > JSP' 카테고리의 다른 글

세션  (0) 2024.06.08
쿠키 로그아웃  (0) 2024.06.08
쿠키 로그인  (0) 2024.06.08
현재 쿠키  (0) 2024.06.08
쿠키 확인  (0) 2024.06.08