小编A-D*_*ddy的帖子

何时将JSESSIONID cookie添加到响应中

我有一个JSF 2.0应用程序,让我们称之为"MyApp",SessionScoped使用下面的代码获取会话并在init上设置路径的bean ...

HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();   //Get request from external context
HttpSession session = request.getSession(false);   //Get session and don't create one if it doesn't exist
session.getServletContext().getSessionCookieConfig().setPath(""); //Set the path in the session's cookie
Run Code Online (Sandbox Code Playgroud)

我的问题是更新的路径("")没有显示在响应会话cookie中JSESSIONID,直到第二个请求到应用程序.第一个请求JSESSIONID在响应中使用默认路径获取cookie,其中包括应用程序的根上下文("/ MyApp").如果我重新加载页面,第二个请求将获得一个JSESSIONID包含更新路径("")的cookie 的响应.

我似乎无法找到有关何时JSESSIONID创建默认cookie并将其添加到响应的任何文档.我不确定更新的会话路径是在第一个响应的JSESSIONIDcookie中设置的,还是由页面的默认JSESSIONIDcookie 设置和覆盖.

问题:

  1. 何时将默认的JSESSIONID cookie添加到响应中?
  2. 是否可以禁用页面的默认JSESSIONID cookie?

cookies session jsf jsessionid jsf-2

2
推荐指数
1
解决办法
4579
查看次数

标签 统计

cookies ×1

jsessionid ×1

jsf ×1

jsf-2 ×1

session ×1