How to Get Session Data In Laravel ?

10-Mar-2023

.

Admin

Hi Guys,

In this example,I will learn you how to get session data in laravel.you can easy and simply get session data in laravel.

In a programming language, session is a great way to store data. It makes easy to handle data without storing in a database.

Session is useful to protect the data that the user wouldn't be able to read or write. Sessions are easier and secure cookies. Sessions are useful user logins, carts etc.

Example:


public function index()

{

$cart[$id] = [

"name" => "Mobile",

"quantity" => 10,

"price" => 10000,

];

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

}

It will help you...

#Laravel 8

#Laravel 7

#Laravel

#Laravel 6