How to Set Session Data In Laravel ?

In this example, I explain how to set session data In laravel. We will show set session data in laravel. We will set session data in laravel using session() function.

In this post, We will learn step by step set session example in laravel. Session most use for store data in globally.

Read Also :  Laravel 8 Image Upload Example

Example : Set sesseion data in laravel

public function index()
    $cart[$id] = [
        "name" => "Mobile",
        "quantity" => 10,
        "price" => 10000,

    session(['cart' => $cart]);

I hope you understand how to set session data and it can help you…