0
0
Flaskframework~5 mins

Session lifetime in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is session lifetime in Flask?
Session lifetime is the time period a user's session data is kept before it expires and is removed.
Click to reveal answer
beginner
How do you set the session lifetime in Flask?
You set the session lifetime by assigning a timedelta value to app.permanent_session_lifetime.
Click to reveal answer
intermediate
What does setting session.permanent = True do in Flask?
It makes the session use the configured permanent lifetime instead of expiring when the browser closes.
Click to reveal answer
beginner
What happens if you do not set session.permanent = True in Flask?
The session will last only until the browser is closed, then it expires immediately.
Click to reveal answer
intermediate
How can you check the current session lifetime value in Flask?
You can check it by printing or logging app.permanent_session_lifetime which shows the timedelta set.
Click to reveal answer
What type of object is used to set app.permanent_session_lifetime?
Abool
Bint (seconds)
Cdatetime.timedelta
Dstring (time format)
If session.permanent is False, when does the session expire?
AWhen the browser closes
BNever
CAfter the configured lifetime
DAfter 24 hours
Which Flask setting controls how long a permanent session lasts?
Aapp.session_life
Bapp.session_timeout
Capp.session_duration
Dapp.permanent_session_lifetime
How do you make a session permanent in Flask?
ASet <code>session.permanent = True</code>
BSet <code>app.permanent = True</code>
CSet <code>session.lifetime = True</code>
DSet <code>app.session.permanent = True</code>
What is the default session lifetime if not set in Flask?
A31 days
BUntil browser closes
C1 hour
D7 days
Explain how Flask manages session lifetime and how you can control it.
Think about how long session data stays and what changes that.
You got /4 concepts.
    Describe what happens when you set session.permanent to True in Flask.
    Focus on session expiration behavior.
    You got /3 concepts.