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

yigitozmen's avatar

Something in blade is clearing my Session, why I don't know

I have a rpg pattern search system. When user enters the page select station and date then starts search, then it posts to search method, after business inside search method, i can transfer all data to the session and recirect to get methods of search then take all data from session then create view with those variables.

I found that something in blade breaks my session, clears it and i got invalid supply in foreach error.

Have you encountered with this kind problem before? I don't know what to do... I can share my view if you want to help..

0 likes
11 replies
yigitozmen's avatar

<img class="img-responsive" src="{{asset('images/vehicles/'.$v->group->name.'/'.$v->in_station->picture)}}" alt="">

I think this line causes the poblem, I went step by step removed everything inside blade template. But this is clearing my session data. Whats problem I dont know

yigitozmen's avatar

@Snapey I wrote here but it disappeard. How can i turn it to code view? I see it in edit panel.

Snapey's avatar

three backticks ``` before and after the code block (as suggested below the edit field)

You can go back and edit earlier posts

Snapey's avatar

Its very unlikely that something in blade will clear the session, especially at the point it is rendering the template. Remember, you have already copied your session to your local variables at this time

Most likely issue is that one of the variables in your foreach loop is missing a relation.

lets change this line for starters;

<img class="img-responsive" src="{{asset('images/vehicles/'.$v->group->name.'/'.$v->in_station->picture) or '---'}}" alt="">
yigitozmen's avatar

@Snapey I did something like this just now. I copied statement inside src and paste there instead of and removed img tags

like this:

{{asset('images/vehicles/'.$v->group->name.'/'.$v->in_station->picture)}}

then it worked well.

I think there is something wrong with img tag?

am i right?

Snapey's avatar

No, there is nothing wrong with your image tag, but it pays to be defensive and code for the possibility that $v does not contain in_station or in_station does not contain picture

You can dd() the variables and all will look ok, but this is stopping on the first pass. Often its one of the $v's later in the loop that is missing something

What EXACT error do you get?

yigitozmen's avatar

When the first time i search it loads all cars and lists to me in blade. When i refresh the page it says invalid supplied on foreach and by the way session token has been changed.

Snapey's avatar

session cookie changes all the time. That is how your session keeps getting extended as you use the site.

Please or to participate in this conversation.