Open TemplarJQ opened 5 years ago
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
this.httpServletRequest.getSession().setAttribute("IS_LOGIN",true);
this.httpServletRequest.getSession().setAttribute("LOGIN_USER",userModel);
//建立redis与uuid之间的联系,需要一个uuid的操作类
redisTemplate.opsForValue().set(uuidToken, userModel);
//超时时间
redisTemplate.expire(uuidToken, 1, TimeUnit.HOURS);
if (data.status == "success")
{
alert("登录成功");
var token = data.data;
window.localStorage["token"] = token;
window.location.href="listitem.html";
}
分布式会话
session
另一种方式
分布式情况