ã¡ã¢ãdjango.contrib.sessionsã®ã»ãã·ã§ã³ãã¼ãæ¯åå¤ããï¼ã¨ããããªè©±ãåºã¦ã¦ãã©ãããåããããã ã£ãã調ã¹ã¦ãã
Djangoã®ãã¼ã¸ã§ã³ã¯1.2.4ã
é©å½ã«æ¸ããviewé¢æ°ã
views.py
from django.http import HttpResponse from random import choice def index(request): x = choice([0, 1, 2]) if x == 0: request.session['a'] = 1 elif x == 1: request.session.flush() return HttpResponse(request.session.session_key + ' ' + str(request.session.keys()) + ' ' + str(x), content_type='text/plain')
- clearã¡ã½ããã§ã¯ã»ãã·ã§ã³ãã¼ã¯å¤ãããªã
- ãã°ã¢ã¦ããªã©ã®å¦çã§ã¯flushã¡ã½ããã使ã(flushã使ãã¨æ¬¡ã®ãªã¯ã¨ã¹ãã§ã¯ã»ãã·ã§ã³ãã¼ãå¤ãã)
- ã»ãã·ã§ã³ã使ã£ã¦ããªãå ´åã¯ãªã¯ã¨ã¹ãæ¯ã«ã»ãã·ã§ã³ãã¼ãå¤ãã
ã©ãããCOOKIEãè¿ã/è¿ããªããã«ã¤ãã¦ã¯èª¿ã¹ã¦ãªããä»åã¯ã»ãã·ã§ã³ã®æåã ãã