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

ayoubadiak's avatar

Laravel API SANCTUM Authentification

Bonjour, En faite j'ai un problème au niveau de mon API. Quand j'authentifie 2 utilisateur et que j'essaye de récuperé l'utilisateur connecté avec (auth()->user()) on me renvoi à chaque fois le premier utilisateur enregistré dans la base de donné. Que dois-je faire pour éviter ce problème ?

0 likes
1 reply
Phil_Dr's avatar

Well, auth()->user() will return the user based on the token that it received, so make sure you are using the correct token or if you share the code here we may help you more.

Please or to participate in this conversation.