When a user logs in to session information, it is saved. And the session information is erased when the user logs out. But when I click the browser button, user information is displayed. Since the session is gone, but we cannot be sure the login operation is in progress. How to solve this problem? question?
----------------------------log out ------------------------------- @RequestMapping(value="logout.htm",method = RequestMethod.GET) public void logOut(HttpSession session,HttpServletResponse response,HttpServletRequest request) throws IOException{ final String refererUrl = request.getHeader("Referer"); response.setHeader(refererUrl, "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); session.removeAttribute("user"); session.invalidate(); response.sendRedirect("index.htm"); } ---------------------------------- login --------------- @RequestMapping(value="/userLogin",method=RequestMethod.POST) public @ResponseBody JsonResponse login(@ModelAttribute(value="user") User user, BindingResult result,HttpServletRequest request,HttpSession session,ModelMap model) throws UnsupportedEncodingException{ JsonResponse res = new JsonResponse(); if(!result.hasErrors()&& userService.findUser(user, request)){ res.setStatus("SUCCESS"); session.setAttribute("user", new String(user.getUsername().getBytes("iso- 8859-1"), "UTF-8")); } else{ res.setStatus("FAIL"); result.rejectValue("username","1"); res.setResult(result.getAllErrors()); } return res; } --------------------------profile -------------------------------------- @RequestMapping(value="myProfile.htm",method = RequestMethod.GET) public String showmyProfile(@ModelAttribute(value="addUser") User user,Model model,HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException{ if(session.getAttribute("user")== null){ response.sendRedirect("index"); }
source share