DEV Community

Discussion on: How to Create a JSON Web Token Using PHP

Collapse
 
pmatt1988 profile image
pMatt1988

Hello neimeier. What I have done for the secret is to add it to the user's row in the database. You will use the payload of the jwt to store the username/user id and when the user attempts to authenticate, you can verify the jwt against the secret stored in the users database row. This makes it easier to invalidate tokens as well, since if the user resets their secret in the database, every device connected will have to authenticate again.