Laravel 8 判断 Session 中是否存在某个值
要确定 Session 中是否存在某个值,可以使用 has 方法。如果该值存在且不为 null,那么 has 方法会返回 true:
if ($request->session()->has('users')) {
//
}
要确定 Session 中是否存在某个值,即使其值为 null,也可以使用 exists 方法。如果值存在,则 exists 方法返回 true:
if ($request->session()->exists('users')) {
//
}