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

amirrossein's avatar

Use session in Laravel API when frontend is Vuejs2

Hi, I have written an application that backend is laravel and frontend is Vuejs2. backend and frontend are totally separated and comunicate to each other with JSON. I want to store a session in laravel and put something like reserve_id in session and track the user with this reserve_id. Although I can't send reserve_id to user because it's not safe so I can't just store it in localstorage. please help! Thanks

0 likes
7 replies
amirrossein's avatar

Dear Sir @topvillas So what if user copy this encrypted value and paste to local storage in another request?

topvillas's avatar

How do you think sessions are handled normally in Laravel?

1 like
topvillas's avatar

It's not a stupid question. You're right to be concerned about security.

36864's avatar

If you're concerned about session hijacking, you'll need to implement some server-side checks to, for example, make sure the user's IP and/or user agent haven't changed since the session started.

I'm not an expert on the subject, but I'm sure there are plenty of resources online on ways to prevent session token hijacking/reuse.

Please or to participate in this conversation.