Django

Django Sessions

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

18 câu hỏi phỏng vấn·
Mid-Level
1

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

Câu trả lời

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?

Câu trả lời

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?

Câu trả lời

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 câu hỏi phỏng vấn

Nắm vững Django cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí