Thursday, May 5, 2016

Django 1.9.5 Cookies. how can I set and display them?

Hey Guys

I have a website which do some calculations in different ways. It will use COOKIES. So how can I set and display the COOKIES? So can you guys guide me.

My code id:

response = HttpResponse('true')
DEFAULT_DATE_FORMAT = 'MM/dd/yyyy'
# Here I am setting my cookies
response.set_cookie('DEFAULT_DATE_FORMAT', DEFAULT_DATE_FORMAT)

# Here I am displaying my cookies
mycookies = request.COOKIES['DEFAULT_DATE_FORMAT']
print(mycookies)

I does not display any error message but it just stop my code execution.
NOTE: My browser's cookies are enabled.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cff8d681-5be5-4754-939e-2294f3cf71b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment