Store JWT token in closure
P粉036800074
P粉036800074 2024-03-26 19:49:01
0
1
390

I heard that JWT tokens are recommended to be stored as follows:

  • access_token in application memory (as the example I gave - closure)
  • refresh_token in Cookie entry (Http only)
Currently, my

access_token is stored in localStorage and is used to check authorization status:

isLoggedIn: state => !!state.token In Vuex

refresh_token Stored in cookies %

P粉036800074
P粉036800074

reply all(1)
P粉464082061

Keeping the token in a closure will depend on the exact implementation you use, and is a bit difficult to demonstrate without any sample code. Maybe you could post part of the code where you get the access token and where you use it?

However, to store the token in memory, it does not have to be a closure. You can even keep it in vue

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!