获取cookie
request.COOKIE.GET
使用cookie
response.set-cookie
views.py
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def cookie_test(request):
r = HttpResponse("hello world")
r.set_cookie('lan', 'python')
r.set_cookie('framework','django')
print(request.COOKIES.get('lan'))
print(request.COOKIES.get('framework'))
return r
浏览器中观察cookie值

获取session
request.session.get
使用session
request.session
views.py
def session_test(request):
request.session['hello'] = 'world'
print(request.session.get('hello'))
return HttpResponse('hello session')
浏览器中查看session —— 加密显示




![[C++核心编程-01]----C++内存四区详细解析](https://img-blog.csdnimg.cn/direct/fa47ee2ea80f4fda9b6c27152cef7d04.png)











![[NSSRound#1 Basic]basic_check](https://img-blog.csdnimg.cn/img_convert/e44781c2d6f7112cb158501699d2e10d.png)



