shiro学习笔记1

shrio会话管理.

http://shiro.apache.org/session-management.html#SessionManagement-UsingSessions

Using Sessions

Subject currentUser = SecurityUtils.getSubject();

Session session = currentUser.getSession();
session.setAttribute( "someKey", someValue);

getSession()是getSession(true)的简写,有则返回,无则创建一个新的并返回.

getSession(false),有则返回, 无返回null.

Custom Session IDs

you can implement the SessionIdGenerator interface and configure the implementation on Shiro’s SessionDAO instance.

Session Validation & Scheduling

SessionValidationScheduler可以清理孤立的会话.

默认的调度是1小时一次.

如果使用redis代替shiro session, 需要有个调度任务, 每隔一段时间查询下失效的session(猜测session每次访问都会被更新时间,当长久不更新的session将被清除)

转载于:https://www.cnblogs.com/liyudong1991/p/11017710.html

猜你喜欢

转载自blog.csdn.net/weixin_33781606/article/details/93367610