Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
Not able to put/get value from session during Ajax request in Laravel 8

We have two ajax request in same webpage.

In first Ajax request we put some value in the session against the key product_id.

$request->session()->put('product_id', 'value'); 

In second Ajax request we try to get value of product_id from session but it returns null or blank

$request->session()->get('product_id'); // Returns null

I'm able to retrieve the value of product_id from session if I try to get it just after putting it into session.

  1. I'm using jQuery to make ajax calls, Both the ajax request use post method.
  2. My routes are in web.php
  3. I've checked the session id in both request it's the same. The code for getting and setting session data is in same controller file.
  4. I'm using database as a session driver.

Can anyone please help me identify the issue as why I'm not able to retrieve product_id from session in second ajax call? Issue is not consistent on some pages.

IMPORTANT : Recently we have upgraded the Laravel version from 5.7 to 8.40. It's working fine in older version.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!