Cookies实现单点登录
1、登录时在action中设置cookies
String username = loginForm.getUsername();String password = loginForm.getPassword();Cookie cookie = new Cookie("sso",new BASE64Encoder().encode((username+password).getBytes()));cookie.setDomain(".192.168.0.145");cookie.setMaxAge(60);cookie.setPath("/");response.addCookie(cookie);
Cookie[] cookies = request.getCookies();if(cookies!=null){ for (Cookie cookie : cookies) { if(cookie.getName().equals("sso")){ String s = cookie.getValue(); s = new String(new BASE64Decoder().decodeBuffer(s)); System.out.println(s); } }}