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

cesarlinux's avatar

UI login and create jwt token for use later in api with axios

Hi, I have a pure laravel 5.5 site running and now I want to put vuejs on some parts. What I'm looking for is: Once the user login using the traditional UI login form then generate a jwt token and use such token in later api calls using axios.

Up today I've just seen API logins that generates the jwt token for later use, I already have the login form working with basic auth (I guess), I'm not using laravel passport.

Wich is the best way to do so?

Many thanks!

0 likes
1 reply
bobbybouwmann's avatar

Yeah, you can simply generate the token and store it in the users table. On login, you need to make sure you store the value in your frontend so your vue code can access it. Localstorage or a cookie works perfectly in most cases ;)

Laravel Sanctum is also something that could work for you: https://laravel.com/docs/7.x/sanctum It was developed with your case in mind.

Please or to participate in this conversation.