User
User

Reputation: 183

Handling the http cookie from GWT module

I have a small confusion about Cookies, whenever the user is logging in we create cookies and adding to the response header.

Cookie cookie = new Cookie("sessionId", "232hghjghghgh"); // http cookie.
cookie.setVersion(1);
cookie.setPath("/");
cookie.setMaxAge(1000);
response.addCookie(cookie);

I think the above will be setting into the browser cache and we can get it from the browser cookies.

In our GWT module we already have an existing implementation like

Cookies.getCookie("sessionId"); // Cookies are from GWT

We are able to get the cookie using above line without using anywhere Cookies.setCookie() method.

Is that because of above line response.addCookie(cookie).

Could any body tell me, is my assumption correct?

Upvotes: 0

Views: 1084

Answers (1)

geert3
geert3

Reputation: 7321

Yes. Your first example is using a javax.servlet.http.Cookie, and this happens on the server side. The latter is purely GWT (i.e. client side) and returns java.lang.String (i.e. the String value of the cookie). But of course both are conceptually the same and setting one on the server will make the other show up on the client.

Upvotes: 1

Related Questions