Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shankarnewton's avatar

Data not stored in Session variable

Issue description:

My session data is not getting stored successfully. I've pretty much tried all possibilities around the internet that I was able to come across, can someone please suggest?

Available Information

  1. Running on Laravel 9
  2. Windows Machine, with XAMPP 3.3
  3. Using PHP 8
  4. My .env file reads: SESSION_DRIVER=file

Code Snippet

//storing the session using the following
session(['history' => time()]);

// retrieving the data using the following
echo session('history');

Things that I've tried so far:

  1. I've tried using web middleware in the routes aswell, but no luck.
  2. Tried the suggestions mentioned here I've added "\Illuminate\Session\Middleware\StartSession::class" in my kernal.php

Am I missing anything here please?

0 likes
4 replies
priyalaks's avatar

Where are storing this ? IS it inside a controller ?

//storing the session using the following
session(['history' => time()]);

// retrieving the data using the following
echo session('history');
priyalaks's avatar

Did u try this way .. ?

$value = $request->session()->push('key', 'default');

Please or to participate in this conversation.