GWT cookies that return null when configured during rpc

I get almost crazy with GWT Cookies,

in one of my applications, I set the cookie to RPC success, but I try to find it elsewhere in my application, it returns null.

I know that when setting a variable in rpc sucess, if we try to access it elsewhere, it returns null, so how can I set a cookie as rpc so that it does not return null?

Edit: - I am doing something like this:

I do in Main.java

RPC.getUserDetails(new AsyncCallback <String>())
{
  public void onSuccess(String result)
  {
      Cookies.set("UserDetails",result);
  }
}

Now in another .java file, when I do Cookies.get("UserDetails"), I get null

+3
source share
2 answers

I had the same problem, and after setting the expiration time, I was able to recover it:

Date now = new Date();
long week = now.getTime();
week = week + (1000 * 60 * 60 * 24 * 7);
Cookies.setCookie("UserDetails", result, week);

, cookie none secure none secure cookie. , , cookie . . cookie.

0

:

Date expires = new Date(System.currentTimeMillis() + (1000 * 3600 * 24));
String categoriesCookieJson = asJson(allCategories);
System.out.println("inserting cat cookie lenth : " + categoriesCookieJson.toCharArray().length + " : " + categoriesCookieJson);
Cookies.setCookie(VU_ME_CATEGORIES_CACHE, categoriesCookieJson, expires);

String categoriesJsonCookieCache = Cookies.getCookie(VU_ME_CATEGORIES_CACHE);
System.out.println("cookie in chache " + categoriesJsonCookieCache);

null cookie ( fb firebug)

inserting cat cookie lenth : 8303 : {"categories":[{"id":"71","name":"Immoblier","children":[{"id":"76","parentKey":"71","name":"Terrain....

cookie chache null

Ok!!! cookie:

inserting cat cookie length : 8303 

0

Source: https://habr.com/ru/post/1783815/


All Articles