通过cookie实现登录功能


参考来源:https://blog.csdn.net/awhip9/article/details/78007600

代码粘贴:

String token = StringUtils.getRandomString(25);
Cookie cookie = new Cookie("token", token);
cookie.setHttpOnly(false);
cookie.setMaxAge(7200);
cookie.setPath("/");
cookie.setSecure(false);
response.addCookie(cookie);

缓存登录数据存取参考使用:

JDK1.7 的ConcurrentHashMap(支持高并发、高吞吐量的线程安全HashMap实现)