类 SaSessionCustomUtil
java.lang.Object
cn.dev33.satoken.session.SaSessionCustomUtil
自定义 SaSession 工具类,快捷的读取、操作自定义 SaSession
样例:
// 在一处代码写入数据
SaSession session = SaSessionCustomUtil.getSessionById("role-" + 1001);
session.set("count", 1);
// 在另一处代码获取数据
SaSession session = SaSessionCustomUtil.getSessionById("role-" + 1001);
int count = session.getInt("count");
System.out.println("count=" + count);
- 从以下版本开始:
- 1.10.0
- 作者:
- click33
-
字段概要
字段 -
方法概要
修饰符和类型方法说明static voiddeleteSessionById(String sessionId) 删除指定 key 的 SaSessionstatic SaSessiongetSessionById(String sessionId) 获取指定 key 的 SaSession, 如果此 SaSession 尚未在 DB 创建,则新建并返回static SaSessiongetSessionById(String sessionId, boolean isCreate) 获取指定 key 的 SaSession 对象, 如果此 SaSession 尚未在 DB 创建,isCreate 参数代表是否则新建并返回static boolean判断:指定 key 的 SaSession 是否存在static StringsplicingSessionKey(String sessionId) 拼接Key: 在存储自定义 SaSession 时应该使用的 key
-
字段详细资料
-
sessionKey
添加上指定前缀,防止恶意伪造数据
-
-
方法详细资料
-
splicingSessionKey
拼接Key: 在存储自定义 SaSession 时应该使用的 key- 参数:
sessionId- 会话id- 返回:
- sessionId
-
isExists
判断:指定 key 的 SaSession 是否存在- 参数:
sessionId- SaSession 的 id- 返回:
- 是否存在
-
getSessionById
获取指定 key 的 SaSession 对象, 如果此 SaSession 尚未在 DB 创建,isCreate 参数代表是否则新建并返回- 参数:
sessionId- SaSession 的 idisCreate- 如果此 SaSession 尚未在 DB 创建,是否新建并返回- 返回:
- SaSession 对象
-
getSessionById
获取指定 key 的 SaSession, 如果此 SaSession 尚未在 DB 创建,则新建并返回- 参数:
sessionId- SaSession 的 id- 返回:
- SaSession 对象
-
deleteSessionById
删除指定 key 的 SaSession- 参数:
sessionId- SaSession 的 id
-