Django

Django Sessions

Session framework, session backends, session middleware, session security, cookie-based vs database sessions

18 perguntas de entrevista·
Mid-Level
1

What is the main role of Django's session framework?

Resposta

Django's session framework allows storing and retrieving arbitrary data on a per-site-visitor basis on the server. It abstracts the process of sending and receiving session cookies, storing data server-side while only sending a session ID to the client via a cookie.

2

Which middleware must be enabled to use sessions in Django?

Resposta

SessionMiddleware is the middleware responsible for managing sessions in Django. It must be present in MIDDLEWARE for request.session to be available. This middleware reads and writes session data, managing the complete session lifecycle.

3

How to access session data in a Django view?

Resposta

Session data is accessed via request.session, which behaves like a Python dictionary. Reading, writing and deleting values works with standard dictionary syntax. Django automatically handles data serialization and persistence.

4

What is the default session backend in Django?

5

How to configure Django to use signed cookie-based sessions?

+15 perguntas de entrevista

Domine Django para sua proxima entrevista

Acesse todas as perguntas, flashcards, testes tecnicos, exercicios de code review e simuladores de entrevista.

Comece gratis