0
0
Expressframework~5 mins

Session-based auth with express-session - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of express-session in an Express app?

express-session helps keep track of user data across multiple requests by storing session info on the server. It allows the app to remember who the user is after they log in.

Click to reveal answer
beginner
How does express-session identify a returning user?

It uses a cookie with a session ID stored in the user's browser. When the user sends requests, the cookie is sent back, letting the server find the matching session data.

Click to reveal answer
intermediate
What is the role of the secret option in express-session?

The secret is a string used to sign the session ID cookie. This helps prevent tampering and keeps sessions secure.

Click to reveal answer
intermediate
Why should session data be stored on the server and not in the cookie itself?

Storing session data on the server keeps sensitive info safe. Cookies can be seen or changed by users, so only a session ID is stored in the cookie to link to server data.

Click to reveal answer
beginner
What happens when you call req.session.destroy() in an Express app?

This deletes the user's session data on the server and removes the session cookie, effectively logging the user out.

Click to reveal answer
What does express-session use to track a user's session?
AA cookie storing a session ID
BLocal storage in the browser
CA hidden form field
DURL query parameters
Which option is required when setting up express-session middleware?
Aport number
Bdatabase URL
Csecret
Dview engine
Where is session data stored when using express-session by default?
AIn the user's cookie
BIn a database automatically
CIn the browser's local storage
DIn memory on the server
What does calling req.session.save() do?
ASaves changes to the session data immediately
BDeletes the session
CCreates a new session
DLogs the user out
Why is it important to use HTTPS with sessions?
ATo speed up the server
BTo protect the session cookie from being stolen
CTo allow more users to connect
DTo enable cookies in the browser
Explain how session-based authentication works using express-session in an Express app.
Think about how the server remembers who you are between page visits.
You got /5 concepts.
    Describe the security benefits of using express-session with a secret and HTTPS.
    Consider how to keep user info safe from attackers.
    You got /4 concepts.