0
点赞
收藏
分享

微信扫一扫

升级chrome浏览器导致网站登录功能不能用

笔者开发一个java web项目,低版本的chrome(74以下)可以正常登录,升级到chrome74不能正常登录,登录成功后url会携带一个jsessionid=xxxxxx。

登录成功那个页面有session,可以通过session.getAttribute获取属性值。其他页面就没有session了。

如果把复制到访问页面后面。例如 http://localhost/111.jsp?jsessionid=xxxxxx也能正常访问。可是tomcat给我的ssession会话凭证的

cookie是JSESSIONID,和jessionid根本就不是一回事。

在老外网站看到有人讨论,说chrome72,问题类似。没有降到72测试。直接升级到chrome76解决问题了。

症状图片

升级chrome浏览器导致网站登录功能不能用_f5

 

​​/toMyProfile.do;jsessionid=DE15789BF54EC8750DB5394BD8A99FA3​​

经笔者测试,上述问题消失,偶尔间又恢复。

最终解决办法:

欺骗浏览器,手工添加JSESSIONID

升级chrome浏览器导致网站登录功能不能用_f5_02

 

 

/**
* 登录
* @param user
* @param model
* @return
*/
@RequestMapping(value = "login.do",method = RequestMethod.POST)
public String login(User user, Model model, HttpSession session, HttpServletResponse response){
Map<String,Object> map = loginService.login(user);
if(map.get("status").equals("yes")){

Integer uid = (Integer) map.get("uid");
String headUrl = (String) map.get("headUrl");

session.setAttribute("uid",uid);
session.setAttribute("headUrl",headUrl);

String sessionId = session.getId();
Cookie cookie = new Cookie("JSESSIONID", sessionId);
cookie.setMaxAge(Integer.MAX_VALUE);
response.addCookie(cookie);

return "redirect:toMyProfile.do";
}else {
model.addAttribute("email",user.getEmail());
model.addAttribute("error",map.get("error"));
return "login";
}
}

参考来源:​​jsessionid所引起的问题 和解决​​

举报

相关推荐

0 条评论