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

jurietylier's avatar

How did you store sanctum token in front end like vue

Is it safe to save the sanctum cookie in cookie storage if not what are the other ways to save it securely

Possible way to save sanctum token in front end because of the issue of linus

0 likes
1 reply
ranto's avatar

You have multiple ways to store the token.

  1. Set it as a Cookie.
  2. Save it on vue storage AKA vuex.
  3. Save it on LocalStorage.

There is not a bettter way to handle the token inside the Front., but those options has pros and cons. For example, if vuex is not setted to be persistent, the moment you press F5, front lose the token. Local storage provide a persistent storage for that token, but needs to be cleared manually when users logs out (people often forget to delete things on local storage)

I think the linus issue related to cookie stealing is prevented using option 2 or 3, but the option you choose is up to you mostly.

Please or to participate in this conversation.