Wednesday, July 30, 2014

Why Cookies will not be stored if setting Timeout = 30 days in GWT?

This is very weird. Ok, the below code works fine

public void setCookie(String cookiesName, String cookiesValue){      final int COOKIE_TIMEOUT = 1000 * 60 * 60 * 24;//1 days      Date expires = new Date((new Date()).getTime() + COOKIE_TIMEOUT);      Cookies.setCookie(cookiesName, cookiesValue, expires);  }  //then  setCookie("currentLang","de");  Collection<String> cookies = Cookies.getCookieNames();  for(String cookie : cookies){          if("currentLang".equals(cookie)){                System.out.println("got currentlang");          }  }  

If i run the above code then I can see output: "got currentlang" However, if I set timeout=30 days final int COOKIE_TIMEOUT = 1000 * 60 * 60 * 24 * 30;//30 days, then nothing got printed out, so "currentLang" has not even been stored if we set 30 days?

Why is that? does Gwt prevent that to happen?

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment