mancuoj / TIL

今天学了什么,记录在 issue 中
0 stars 0 forks source link

Auth #7

Open mancuoj opened 6 days ago

mancuoj commented 6 days ago

Session

Sessions are a way to persist state in the server.

It is especially useful for managing the authentication state, such as the client's identity.

We can assign session with a unique ID and store it on the server to use it as a token.

The client can then associate subsequent requests with a session, and by extension, with the user, by sending its ID.

Session IDs can either be stored using cookies or local storage in browsers.

We recommend using cookies since it provides some protection against XSS and the easiest to deal with overall.

User will use a session token linked to a session instead of the ID directly.

The session ID will be the SHA-256 hash of the token.

The