clear cache of Me when logout

This commit is contained in:
小喵 2023-08-27 22:55:49 +08:00
parent d95d78f5a2
commit ad6d884437
Signed by: mt
GPG key ID: CD321C269EC63BB6
3 changed files with 14 additions and 2 deletions

View file

@ -64,6 +64,7 @@ class App
public static function unsetU(): void
{
Redis::unsetMe($_COOKIE['u'] ?? '');
try {
setcookie('u', null, [
'expires' => time() - 3600,
@ -128,8 +129,8 @@ HTML,
try {
$u = static::getU();
if ($u === null) return null;
$cachedMe = Redis::getCachedMe($_COOKIE['u']);
if ($cachedMe === null) return Redis::cacheMe($_COOKIE['u'], Auth::getMe($u));
$cachedMe = Redis::getCachedMe($_COOKIE['u'] ?? '');
if ($cachedMe === null) return Redis::cacheMe($_COOKIE['u'] ?? '', Auth::getMe($u));
return $cachedMe;
} catch (Exception) {
error_log('Failed to getMe.');