²âÊÔ»·¾³£ºJDK1.5¡¢Tomcat5.5 1.ÉèÖÃCookie 2.¶ÁÈ¡Cookie¡¡3.ɾ³ýCookie¡¡4.×¢Ò⣺¼ÙÉè·¾¶½á¹¹ÈçÏÂ
¡¡¡¡²âÊÔ»·¾³£ºJDK1.5¡¢Tomcat5.5
¡¡¡¡1.ÉèÖÃCookie
¡¡¡¡1 Cookie cookie = new Cookie("key", "value").
¡¡¡¡2 cookie.setMaxAge(60). //ÉèÖÃ60ÃëÉú´æÆÚ£¬Èç¹ûÉèÖÃΪ¸ºÖµµÄ»°£¬ÔòΪä¯ÀÀÆ÷½ø³ÌCookie(ÄÚ´æÖб£´æ)£¬¹Ø±Õä¯ÀÀÆ÷¾ÍʧЧ¡£
¡¡¡¡3 cookie.setPath("/test/test2"). //ÉèÖÃCookie·¾¶£¬²»ÉèÖõĻ°Îªµ±Ç°Â·¾¶(¶ÔÓÚServletÀ´ËµÎªrequest.getContextPath() web.xmlÀïÅäÖõĸÃServletµÄurl-pattern·¾¶²¿·Ö)
¡¡¡¡4 response.addCookie(cookie).
¡¡¡¡2.¶ÁÈ¡Cookie
¡¡¡¡1 1//¸Ã·½·¨¿ÉÒÔ¶ÁÈ¡µ±Ç°Â·¾¶ÒÔ¼°¡°Ö±½Ó¸¸Â·¾¶¡±µÄËùÓÐCookie¶ÔÏó£¬Èç¹ûûÓÐÈκÎCookieµÄ»°£¬Ôò·µ»Ønull
¡¡¡¡2 2Cookie[] cookies = request.getCookies().
¡¡¡¡3.ɾ³ýCookie
¡¡¡¡1 Cookie cookie = new Cookie("key", null).
¡¡¡¡2 cookie.setMaxAge(0). //ÉèÖÃΪ0ΪÁ¢¼´É¾³ý¸ÃCookie
¡¡¡¡3 cookie.setPath("/test/test2"). //ɾ³ýÖ¸¶¨Â·¾¶ÉϵÄCookie£¬²»ÉèÖøÃ·¾
ÏÂÒ»Ò³£ºÔĶÁ¡¶JavaС¼¼ÇÉ£º¹ØÓÚCookieµÄ²Ù×÷¡·µÄÈ«ÎÄ