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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners