Edw*_*win 2 cookies jsp servlets
我有以下设置:
现在我有一个应用程序loc可以为子域设置一些cookie loc3。我看到 cookie 在 chrome 网络响应中设置(或假设设置)。
Set-Cookie: MY_COOKIE=YUMM; domain=loc3.localdomain;
expires=Fri, 21-Jun-2019 10:48:58 GMT; path=/coolApp/bro
Run Code Online (Sandbox Code Playgroud)
然后在应用程序 atloc我有一个按钮,可以将用户发送到另一个应用程序 at loc2,将用户重定向到loc3at loc3.localdomain:8092/coolApp/bro/something/more。因此,此时我应该在 的应用程序请求中看到 cookie loc3,但我没有。
Cookie 设置:
FacesContext facesContext = FacesContext.getCurrentInstance();
//facesContext.getExternalContext().addResponseCookie("TEST", "TEST", properties); tried this too
//then in properties will be the maxAge, path and domain set
Cookie cookie = (Cookie) facesContext.getExternalContext().getRequestCookieMap().get("MY_COOKIE");
if(cookie == null){
cookie = new Cookie("MY_COOKIE", "YUMMM");
}
cookie.setMaxAge(31536000);
cookie.setPath("/coolApp/bro");
cookie.setDomain("loc3.localdomain"); // I've tried ".localdomain" too
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.addCookie(cookie);
Run Code Online (Sandbox Code Playgroud)
知道这个设置有什么问题吗?
基于此(https://curl.haxx.se/rfc/cookie_spec.html),域应包含至少 2 个点,因此答案是使用 localhost 的其他别名来模拟我的子域。就像是:*.example.com
更改域名后,一切都按预期进行。
| 归档时间: |
|
| 查看次数: |
7183 次 |
| 最近记录: |