I’ve got a single sign-on emulator that does a redirect and sets a cookie. I’ve got a middleware (GenerateMenus) that checks the cookie and loads the auth information from the SSO emulator, rather than the default auth stuff, if that cookie is set. It works fine except right after clicking the login button.
The GenerateMenus middleware is called before the cookie appears, so it thinks the user isn’t logged in and gives the wrong display. Once the page loads, a refresh or form submit will give the right menu.
So, I think the cookie is being set after the middleware runs. Any looking at cookies I do before then doesn't show the new cookie. Any ideas on how to find this cookie before it becomes a cookie? scratches head
Setting the cookie:
return redirect() ->to(RegistrationController::GetMemberRoute($member_id)) ->withCookies([SsoEmulator::BakeCookie($member_id, $member_data)]);
The cookie check that fails:
My web middleware group:
'web' => [ // Utilize custom cookie encryter. \App\Http\Middleware\SpecialEncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\SetLocalization::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\GenerateMenus::class, ],