쿠키 저장 및 제거

920 단어 cookie
1.  cookie    
HttpServletResponse response = ServletActionContext.getResponse(); 
Cookie c1 = new Cookie("username","hzh");
c1.setMaxAge(3600);
response.addCookie(c1);

Cookie c2 = new Cookie("password","123");
//       1  ,    
c2.setMaxAge(3600);
response.addCookie(c2);

/**
     cookie  ,      password,       username      ,          ,       (             ,    ),      ,    c1.setMaxAge(3600)  response.addCookie(c1);  
*/

2.  cookie  

Cookie[] cookies = request.getCookies();
            for(Cookie c :cookies ){
                System.out.println(c.getName()+"--->"+c.getValue());
            }

         :
username--->hzh
password--->123
JSESSIONID--->33BEAF95C526E0DDCF6A64990E533845


좋은 웹페이지 즐겨찾기