Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

al.mootasem's avatar

Why is laravel cookie not being decrypted during axios requests?

When retrieving a cookie (Laravel 8), I get the actual string (decrypted) if I run the request from the browser but the encrypted version when I run an axios request.. why?

This is how I'm setting/getting the cookie:

public static function getCartId(): string
{
    if (!$cookie = Cookie::get(self::COOKIE_NAME)) {
        $cookie = (string) Str::uuid();
        Cookie::queue(Cookie::forever(self::COOKIE_NAME, $cookie));
    }

    return $cookie;
}

I understand cookies ar encrypted/decrypted in EncryptCookies middleware which I made sure is running during both requests.

0 likes
0 replies

Please or to participate in this conversation.