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

murilo's avatar
Level 10

Redis Cart Session ( backend ) + VUE SPA Application ( frontend )

Hello , I have a question. I have been working with Redis , and with VUE SPA . I want store some user navigation data , like a shopping cart and other datas . I could store that in VUE local storage . but in this project , I am storing many things . and it is a SSR Application . ( I could not use local storage, instead I am using cook that is smaller ). So , I am thing to store evething in Redis .

The problem is that I must have some reference , when I send this session to Laravel / Redis . maybe a session ID , showing that , this user own this session .

I could have a sesion ID in VUE and send it to redis, that way , Redis get all the user session navigation . So I am thinking -

In Front / VUE  - Store the session ID  if exists , send to Laravel a request  .
In Back End / Larave - Redis - If the session exists , get all data of that user . 
If does not exists create a session ID and returns the session ID .

I would like to know if has some best practice for doing that . I didn't find anything about that . I could send as well a JWT , and store that in VUE . it would be other option . or I could create a session ID based on datetime and clear all , old session IDS that is more than 10 days old with Laravel Schedules.

0 likes
1 reply
martinbean's avatar

You’ve built a SPA. Now you’re wanting to store stuff in a server-side cache. I really wish people would pick whether they want their apps to run on the client or the server…

If you have a SPA then you should have an API for your cart. Store the cart on the server. Use authentication to retrieve and modify the cart, like I assume any other feature in your SPA.

Please or to participate in this conversation.