Code pieces about cookie

zhaozj2021-02-16  164

Set cookie

IF (cookievalue == null || cookievalue.equals (")) {cookievalue =" - " TID " - ";} else {cookievalue =" - " TID cookievalue.replaceAll (" - " tid " - "," - ");} // out.println (" cookievalue = " cookievalue; cookie = new cookie (cookiename, cookievalue); cookie.setMaxage (3600); response.addcookie (cookie);

Get cookie

String cookiename = "LatestViewType"; String CookieValue = ""; cookie cookies [] = request.getCookies (); cookie cookie = null; if (cookies! = Null) {for (int i = 0; i

Cookie = cookies [i];

IF (cookie.getname (). Equalsignorecase (cookiename)) {

CookieValue = cookie.getValue ();

Break;

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-8640.html

New Post(0)