久久久久无码精品,四川省少妇一级毛片,老老熟妇xxxxhd,人妻无码少妇一区二区

Java認(rèn)證考試:如何設(shè)置和刪除cookie

時間:2024-11-11 14:19:27 JAVA認(rèn)證 我要投稿
  • 相關(guān)推薦

Java認(rèn)證考試:如何設(shè)置和刪除cookie

  -

Java認(rèn)證考試:如何設(shè)置和刪除cookie

  /**

  * 刪除cookie

  */

  public static void clearCookie(HttpServletRequest request,HttpServletResponse response, String path) {

  Cookie[] cookies = request.getCookies();

  try{

  for(int i=0;i《cookies.length;i++) {

  //System.out.println(cookies[i]。getName() + “:” + cookies[i]。getValue());

  Cookie cookie = new Cookie(cookies[i]。getName(), null);

  cookie.setMaxAge(0);

  cookie.setPath(path);//根據(jù)你創(chuàng)建cookie的路徑進(jìn)行填寫

  response.addCookie(cookie);

  }

  }catch(Exception ex) {

  System.out.println(“刪除Cookies發(fā)生異常!”);

  }

  }

  public static void setCookie(HttpServletResponse response, String name, String value, String path) {

  if (logger.isDebugEnabled()) {

  logger.debug(“Setting cookie ‘” + name + “’ on path ‘” + path + “’”);

  }

  Cookie cookie = new Cookie(name, value);

  cookie.setSecure(false);

  cookie.setPath(path);

  cookie.setMaxAge(Constants.COOKIE_INVALID_TIME);

  response.addCookie(cookie);

  // logger.info(“setCookie 完成……。”);

  }

  //調(diào)用

  String cookiename = “vbo”;

  String cookievalue = “cb”;

  String path = “/”;

  setCookie(response, cookiename , cookievalue , path);

  clearCookie(request,response,path);//如果有name的話,方法也要增加name過去才能匹配

【Java認(rèn)證考試:如何設(shè)置和刪除cookie】相關(guān)文章:

java認(rèn)證考試科目設(shè)置10-24

php 刪除cookie方法詳解10-24

JAVA認(rèn)證考試細(xì)則06-10

java認(rèn)證考試介紹07-31

Linux認(rèn)證考試科目設(shè)置07-12

微軟認(rèn)證考試科目設(shè)置07-16

sun java認(rèn)證考試介紹10-23

JAVA認(rèn)證考試費(fèi)用06-25

java認(rèn)證考試細(xì)則介紹08-19

Sun java認(rèn)證考試答案11-06