I'm trying to save the latest time in cookies. So after each controller call, I blocked the call using a posthandle of handler interceptor. In that I am updating the value in the cookie but the price is not being updated. Nobody knows why it is not working.
code:
@Override public void Posthandl (Acteepisaarlet request, Actiteepisrvet response reaction, the object handler, model and view x) throws Exception {boolean Haset = true; {(Request.getSession (). GetAttribute ("userId") = null} {{cookie cookie: request.getCookies ()} {if ("RequestTime" .equals (cookies.getName ())} {isSet = false is ; Cookies.setValue (Long.toString (System.currentTimeMillis ())); Response.addCookie (cookies); }} If (isSet) {cookie cookie = new cookie ("request time", long.stustring (system content time milliseau)); Response.addCookie (cookie); }}}}
You set a cookie path when you create a cookie Should you wish to share this cookie in your project, you should request "/" such as
cookie (request.getSession (). GetAttribute ("userId") = null ) {Cookie cookie = new cookie ("request time", long.stustring (system content-time milliseau)); Cookie.setPath ("/") response.addCookie (cookie); } The default cookie path is the current request URL
Note: If you want to share cookies from different subdomains, you should also set the cookie domain.
cookie.setDomain ("test.com")
Comments
Post a Comment