Search code examples
htmllaravelforms

How to get sessions in Laravel


I bought a Laravel website script, but I want to create a custom form page by myself, and I don't really know how to fetch out data using the session if the user is logged in. Please, can anyone help?

<input type="text" name="email" value="{{$user->email}}">

How do I add a session so that the input will be able to display the user's email?


Solution

  • Take a look at the docs

    You can do something like:

    $value = $request->session()->get('key');
    

    Or even call the global session helper:

    $value = session('key');