gpt4 book ai didi

java - 更新 JSESSIONID cookie 值

转载 作者:行者123 更新时间:2023-12-01 10:03:26 27 4
gpt4 key购买 nike

我正在尝试更新 JSESSIONID 值,如下所示,但它为每个请求创建一个新的 JSESSIONID cookie。

    Cookie[] cookies = httpRequest.getCookies();
Cookie jsessionCookie = null;
Cookie hazelcastCookie = null;
if (cookies != null) for (Cookie cookie : cookies) {
if (cookie.getName().equals(JSESSION_COOKIE_NAME))
jsessionCookie = cookie;
else if (cookie.getName().equals(HAZELCAST_COOKIE_NAME)) hazelcastCookie = cookie;
}
if (jsessionCookie != null && hazelcastCookie != null
&& jsessionCookie.getValue() != hazelcastCookie.getValue()) {
jsessionCookie.setValue(hazelcastCookie.getValue());
httpResponse.addCookie(jsessionCookie);
LOGGER.log(Level.DEBUG,
"Updated jsessionCookie value with hazelcastCookie --> " + jsessionCookie.getValue());
}

我应该进行哪些更改才能仅更新 JSESSIONID 值,而不是为每个请求创建一个新值?

更新

请求 header

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:WebDAV.activeX=false; JSESSIONID=HZ9542C5A55A7142A28935DFF96746230F; hazelcast.sessionId=HZ9542C5A55A7142A28935DFF96746230F; JSESSIONID=HZ9542C5A55A7142A28935DFF96746230F; sessionIdForCognos=HZ9542C5A55A7142A28935DFF96746230F; _sd3_session_id=5436c0eebe806f38ca8d1e2867338e00

响应 header

Cache-Control:no-cache
Connection:Keep-Alive
Content-Encoding:gzip
Content-Language:en-US
Content-Length:6538
Content-Type:text/html;charset=utf-8
Date:Thu, 14 Apr 2016 22:20:36 GMT
Expires:Wed, 31 Dec 1969 23:59:59 GMT
Keep-Alive:timeout=70, max=57
Pragma:no-cache
Server:None
Set-Cookie:JSESSIONID=508E10266957BFF95874CEBFECF5FBAF.qa-trunk-n2; Path=/Passport; Secure; HttpOnly
Set-Cookie:hazelcast.sessionId=HZ9542C5A55A7142A28935DFF96746230F; Path=/Passport
Set-Cookie:JSESSIONID=HZ9542C5A55A7142A28935DFF96746230F

最佳答案

如果要设置现有 cookie 的值,则 cookie 的以下字段必须全部相同:

  1. 域名
  2. 路径
  3. 安全
  4. 仅限 http
  5. 姓名

关于java - 更新 JSESSIONID cookie 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36633321/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com