【发布时间】:2015-02-21 15:10:42
【问题描述】:
我对 Cookie 有点困惑,每当用户登录时,我们都会创建 cookie 并添加到响应标头中。
Cookie cookie = new Cookie("sessionId", "232hghjghghgh"); // http cookie.
cookie.setVersion(1);
cookie.setPath("/");
cookie.setMaxAge(1000);
response.addCookie(cookie);
我认为以上内容将被设置到浏览器缓存中,我们可以从浏览器 cookie 中获取它。
在我们的 GWT 模块中,我们已经有一个现有的实现,例如
Cookies.getCookie("sessionId"); // Cookies are from GWT
我们可以使用上面的代码来获取 cookie,而无需使用任何 Cookies.setCookie() 方法。
是不是因为上面一行 response.addCookie(cookie)。
谁能告诉我,我的假设是否正确?
【问题讨论】: