Support the ongoing development of Laravel.io →
Security Requests Session

Hello, When I delete all cookies and reload my website in firefox all http requests are returning 500 internal server error(token mismatch exception). Actually I'm sending correct token!(I'm sure at 100% because when I reload site on chrome it works). Problem is that those http requests aren't sending laravel's cookies - xsrf-token and laravel_session. Why? They are just not generating on page load in firefox..In chrome they generates but it's causing same error because they generate just too late or something because when I reload website it works then.

Huh? I'm consufed what should I do..(try to manually somehow create those cookies in javascript on start?)

Thanks for any help.

Edit: I realized laravel's not creating cookies only when I redirect threw handler.php like so:

public function render($request, Exception $e)
    {
        if($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException)
        {
        // always redirect to homepage
        // some code
            return response()->view('design', compact('something'));
        }
        return parent::render($request, $e);
    }

how to update it to return view with cookies? Something like:

 return response()->view('design', compact('something'))->withCookie('laravel_session', howShouldIAccessIt?)->withCookie('XSRF-TOKEN', huh?);
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

fant0m fant0m Joined 20 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.