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

amitsolanki24_'s avatar

Display user data from site A to B when user update their details in laravel

Hello everyone, so right now I have two website site A and B. Both using same database.

Whenever user login or update their profile details like name , profile pic I have set in the session.

But I'm getting issue when I update my details suppose site A and then check in site B it's showing old data because I have displayed user data from session. If user again login then display as aspected.

0 likes
10 replies
martinbean's avatar

@amitsolanki24_ Well why do you have two applications in the first place if they’re just accessing the same database, and a user should have the same login on both sites?

amitsolanki24_'s avatar

@martinbean one site is a blogging site and other is same like social media . Both have different features and domain but both use same users table.

Snapey's avatar

Then dont put the data in session. You are causing the data to be effectively cached with no means to clear the cache

amitsolanki24_'s avatar

@snapey If I don't put fata into session than I need to fetch login user details on every page unnecessary db query.

Snapey's avatar

@amitsolanki24_ I've news for you. Auth does this anyway in order to validate the user. There is always a user model query at the start of every authenticated request.

This is how Auth::user() always has valid data about the user.

You are putting data in the session pointlessly

amitsolanki24_'s avatar

@Snapey yes Auth::user() has user data but I'm getting user data from calling API.

How can I dipplay updated data when i get user data from api

Snapey's avatar

I'm getting user data from calling API

How do you log the users in? How do they stay logged in on this site?

amitsolanki24_'s avatar

@martinbean

I don't want to refresh page without using react js a d vue js than convert into iconic app.

And im using session because it's more secure than localstorage and session stored data for a limited time.

Please or to participate in this conversation.