Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda