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

NoobDev's avatar

Sanctum api token inside a cookie

I'm building a project with angular and laravel as backend. I've decided to use sanctum as api and I was thinking to store the token inside a cookie right after the login. Then, for each request i would take it and extrapolate the token inside to permit the normal flow. Is it a bad idea ? Thanks in advance

0 likes
2 replies
vincent15000's avatar

That's perhaps not a good idea. For security reasons you should use the session storage sessionStorage rather than a cookie.

NoobDev's avatar

@vincent15000 I misunderstood your message so I'm editing my reply; With sessionStorage I won't be able to keep a user connected. Am I wrong ? And why would it be safer ?

Please or to participate in this conversation.