f0ntana's avatar

Save my Api Token

i do an API with Laravel, and i want to do a Client with Lumen, i want use Lumen to consume my api, with lumen 5.4 don't have session() more, so where can i save my api JWT token? after login? to use with my others request?

thanks

0 likes
3 replies
viktorivanov's avatar
Level 15

Store your token on the client side, for example on a cookie (preferable) or in localStorage/ sessionStorage. And pass that with every request to the API where you check the validity of the token.

2 likes
viktorivanov's avatar

@f0ntana, so your laravel driven API will first have en endpoint to sign a cookie, right? I mean you'll pass some username/password credentials and if they are correct the API can response with the token. So that token can be stored on a cookie. After that the client will pass the token with every request to the API. API will probably have some parsing and checking (probably in a middleware) on the routes of your choice whether the token is valid and not expired.

Please or to participate in this conversation.