Source: iwasherefirst2.medium.com

How do Laravel sessions work?

Category: Laravel, PHP

Before we start, let us recap what a session actually is: Your web application can store whatever it wants on the clients cookie. For example, the username and the information that the user is logged in. Now storing this information in the cookie as plain text is a bad idea, because every client can edit his cookies. Thus, a malicious person could just state in the cookie that he is a superadmin and logged in. In order to prevent that, there is usually only a session_id stored in the cookie.

You can check the request in your browser in the inspection window in the network tap.

You simple have to call session_start() in your script and then you can access the session data through the array $_SESSION.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners