Laravel sessions vs PHP session

Whats the difference between session and cookies again?

All locally stored cookies for a single website
Cookies send in Header by HTTP request

So everyone uses sessions?

How to create a session in PHP?

How does Laravel manages its session?

Storage drivers

  • Database
  • File
  • Cookie
  • memcache
  • PHP array
  • AWS dynamoDB
'driver' => env('SESSION_DRIVER', 'file'),
'files' => storage_path('framework/sessions'),

How to specify Laravel session duration?

'lifetime' => 120,'expire_on_close' => false,
'cookie' => env(
str_slug(env('APP_NAME', 'laravel'), '_') . '_session'

What is Laravels Garbage Collector?

protected function collectGarbage(Session $session)
$config = $this->manager->getSessionConfig();

// Here we will see if this request hits the
// garbage collection lottery by hitting
// the odds needed to perform garbage collection
//on any given request. If we do
// hit it, we'll call this handler to let it delete
// all the expired sessions.
if ($this->configHitsLottery($config)) {
'lottery' => [2, 100]

Will remember me work beyond session life time?

Whats the difference between Laravel cache and Laravel session?




Completed my PHD in math. Since 2016 I work full-time on a family startup.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Monolith vs Microservices: Choosing the Right Architecture for Your Organization

Cleverit: Providing agility and fasteness through Devops in Chile

Understanding Coveo for Sitecore

This image shows how a search is being done in Sitecore using Coveo.

Directx 11 Download Directx 11 For Windows

6 Python Concepts You Should Know to Stand Out in an Interview

Why Kotlin Multiplatform ?

Staking on UMEE Network

Featured Story 6 — A Different「Dfinity」| What is Dfinity’s Mercury?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dr. Adam Nielsen

Dr. Adam Nielsen

Completed my PHD in math. Since 2016 I work full-time on a family startup.

More from Medium

Laravel 8 full text search: Scout

What’s New in Laravel 9: New Features of Laravel 9


SEO-friendly breadcrumbs in Laravel that Google will love

A newspaper, a sweater, a notebook with Google opened in the browser, a pitcher full of flowers — on a wooden table. Four wooden chairs around it.