-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Cookies, something comes, something does not come, I can not understand what the problem is - sometimes it can be cut from the third or fourth click, sometimes from the first, from what it can arise? I use tomkat 6.0.26
why not try the latest tomcat, and set cookies like this:
HttpServletResponse response = (HttpServletResponse) Executions.getCurrent().getNativeResponse();
Cookie userCookie = new Cookie("user", username);
userCookie.setMaxAge(604800);
userCookie.setPath("/");
response.addCookie(userCookie);
That works for me as well!
Adding cookie - Example:
Cookie cookie = new Cookie("MyCookie", codedCookieString);
cookie.setMaxAge(60*60*24*30); //store 30 days
String cp = Executions.getCurrent().getContextPath();
// if path is empty, cookie path will be request path, which could couse problems
if(cp.length() == 0) {
cp = "/";
}
cookie.setPath(cp);
//cookie.setDomain(pattern);
((HttpServletResponse)Executions.getCurrent().getNativeResponse()).addCookie(cookie);
Reading cookies - Example:
Cookie[] cookies = ((HttpServletRequest) Executions.getCurrent().getNativeRequest()).getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
String cookieName = cookie.getName();
Asked: 2019-06-25 18:26:39 +0800
Seen: 17 times
Last updated: Sep 11 '19
wrong valueException come in front of modal popup [closed]
Use parameters in a conditional @command
Problems with multiple press and onCtrlKey
MVVM @save on the fly [closed]
Unable to activate destroyed desktop
org.zkoss.zk.ui.UiException: java.lang.ClassNotFoundException
How to put a image or Letter over image on a specific XY Coordinate
As you phrased your question I can't tell whether it's a tomcat or a ZK problem. Can you please provide an example of how you are trying to set the Cookie? And especially how this is click related?
cor3000 ( 2019-06-26 10:31:15 +0800 )edit