Using basic sessions and cookies
There will be times when we want to pass data from one page of our app to another page without needing to store the information in a database. To accomplish this, we can use the various Session
and Cookie
methods that Laravel provides us.
Getting ready
For this recipe, we need a standard Laravel installation.
How to do it…
For this recipe, follow the given steps:
In the
views
folder, create a file namedsession-one.php
with the following code:<!DOCTYPE html> <html> <head> <title>Laravel Sessions and Cookies</title> <meta charset="utf-8"> </head> <body> <h2>Laravel Sessions and Cookies</h2> <?= Form::open() ?> <?= Form::label('email', 'Email address: ') ?> <?= Form::text('email') ?> <br> <?= Form::label('name', 'Name: ') ?> <?= Form::text('name') ?> <br> <?= Form::label('city', 'City: ') ?> <?= Form::text('city') ?>...