From b99a975de1504e120e8e4a56e501a555700eab88 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Fri, 14 Jul 2023 13:45:42 +0200 Subject: [PATCH] Switched to session storage --- app/Http/Controllers/AdminController.php | 2 +- app/Http/Middleware/Impersonate.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index bea8bf2f3..57d697d65 100755 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -680,7 +680,7 @@ public function authAs(request $request) $user->remember_token = null; $user->save(); - setcookie("display_auth_nav", "", time() - 3600, "/"); + $request->session()->forget('display_auth_nav'); Auth::loginUsingId($userID); diff --git a/app/Http/Middleware/Impersonate.php b/app/Http/Middleware/Impersonate.php index a20a9a0c3..3a9228093 100644 --- a/app/Http/Middleware/Impersonate.php +++ b/app/Http/Middleware/Impersonate.php @@ -35,10 +35,11 @@ public function handle($request, Closure $next) } Auth::loginUsingId($id); - setcookie("display_auth_nav", "true", time() + (10 * 365 * 24 * 60 * 60), "/"); + $request->session()->put('display_auth_nav', true); + $request->session()->save(); } -if(isset($_COOKIE['display_auth_nav'])) { +if($request->session()->has('display_auth_nav')) { if (file_exists(base_path(findAvatar($id)))) { $img = 'avatar'; } elseif (file_exists(base_path("assets/linkstack/images/").findFile('avatar'))) { @@ -148,8 +149,8 @@ function submitForm() { return $response; } else { - if(isset($_COOKIE['display_auth_nav'])) { - setcookie("display_auth_nav", "", time() - 3600, "/"); + if($request->session()->has('display_auth_nav')) { + $request->session()->forget('display_auth_nav'); Auth::logout(); } return $next($request);