Session Management

Uses of the Session

The session is used for storing data that lasts between HTTP requests (in other words, between page loads / refreshes).

The session is useful for storing:

Using the Session

Set a value:

session['key'] = value

Get a value:

value = session.get('key')

With a default if not present:

value = session.get('key', 'default')

Delete a value:

session.pop('key', None)

Clear all values

session.clear()