InterviewSolution
| 1. |
How to use file-based sessions? |
|
Answer» Session data is stored on the server. DJANGO creates a random UNIQUE string called session-id or SID and Django associates that ID or SID with the data. As a VALUE to the browser, the server SENDS a cookie named session-id containing SID as value. On-page request, the browser sends a request containing a cookie with SID to the server. To retrieve this session data and make it accessible in code, Django uses this SID. Django generated SID is 32 characters long random string. Django support for anonymous sessions. Django session framework allows to store and retrieve arbitrary data on PER site visitor basis. Seesions are implemented via middleware. To enable session functionality, edit MIDDLEWARE_CLASSES setting and make sure 'django.contrib.sessions.middleware.SessionMiddleware' is added. Set the SESSION_ENGINE setting to "django.contrib.sessions.backends.file" to use file-based sessions. Also, set the SESSION_FILE_PATH setting to configure where Django store session files. |
|