How to set or get a cookie value in django
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
to set or get a cookie value in django:
if request.method=="GET": tutorial = request.COOKIES.get('car_type', 'Saab') return render(request, 'cookies/cookie.html') elif request.method =="POST": payment_id = request.POST.get('cars', '') # response = HttpResponse("Cookie Set for Cars") response = render(request, 'cookies/cookie.html') response.set_cookie('car_type', str(payment_id),max_age=30) return response