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

Andreas94's avatar

read cookie content

I have a cookie called: trophylist by default its value is 'list' when I press a button it becomes grid.

how do I check the value inside the cookie? I did this, but it doesn't work

          @if (\Cookie::get('trophylist') == 'list')
            @include('front.component.trofei.table')
          @else
            aaaaaaaaa
          @endif

now the cookie content is 'list' and it shows me 'aaaaaaaaaa', why?

0 likes
2 replies
drewdan's avatar
   @dd(\Cookie::get('trophylist')

Should dump the value in the blade file. Or just check your browser dev tools for the cookie

Andreas94's avatar
Andreas94
OP
Best Answer
Level 2

I tried to put:

   @dd(\Cookie::get('trophylist')

and it prints me on the blade exactly

(\Cookie::get('trophylist')

i am using Laravel 5.8

Edit:

was missing one ), I print null.

Another Edit:

I solved it by inserting the name of the cookie in Http\Middleware\EncryptCookies.php

Please or to participate in this conversation.