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

Araw's avatar
Level 1

Laravel Session

I Want to Mail Laravel Session Array Value ...But I received a Mail but get only Last value of Session Array....

This is How I Store Value in Session Array

   Session::put('order_placed_session', ['item_name' => $order_item->Transistor_manufacturer,'item_quantity'=>$order_item->item_quantity,'order_id'=>$order_id]);

This is My Blade File



        @foreach (Session::get('order_placed_session') as $product_id)
   
    <h1> {{$product_id}}</h1>
@endforeach

0 likes
1 reply
Nakov's avatar

@araw can you try dumping out before the view is rendered what do you have in the session?

Also if you use a Mail class you can store the data from the session in a variable and pass it through instead of using the session within the mail.

And make sure you have values for each of the items, because it might be rendered meaning you might have two empty <h1> tags and you only see the one that has value.

Please or to participate in this conversation.