I could set the cookies with response.set_cookie() and response.cookies[]
as shown below. *I use Django 4.2.1:
# "my_app1/views.py"
from django.http import HttpResponse
def test(request):
response = HttpResponse('Test')
response.set_cookie('first_name', 'John') # Here
response.cookies['last_name'] = 'Smith' # Here
return response
Then, I could only delete response.set_cookie()
's cookie first_name
rather than response.cookies[]
's cookie last_name
with response.delete_cookie() as shown below:
# "my_app1/views.py"
from django.http import HttpResponse
def test(request):
response = HttpResponse('Test')
response.delete_cookie('first_name') # Deleted
response.delete_cookie('last_name') # Undeleted
return response
So, what is the difference between response.set_cookie()
and response.cookies[]
in Django?