Ii. Token problems and Usage Details
What is a Token?
Token can be understood as a Token. The server verifies the Token to determine whether you have the permission for this operation. An important feature of Token is validity. Generally, Token is valid only within a certain time range. Is a flowchart of the login module, showing a basic application of Token.
Images are from the network and are infringed.
Simple Token implementation
A simple Token can be generated by the key, timestamp, and content. During network transmission, base64_encode is used for transmission. After the server uses base64_decode decoding, it verifies the Token validity. A Token generation method is as follows.
Where is the Token stored?
The Token can be stored in three ways based on the actual application type.
It exists in a MySQL-type database. The benefits of doing so can be stored in large quantities and data persistence.
Memory, such as Cache. The advantage is that the verification speed is fast.
No storage. Each time the server uses an algorithm to verify the Token validity.
Open Source project at github: https://github.com/moyiblog/JWT