-1

i use django 2.0.9.

I am creating a project in which the display is changed by changing the value of the cookie.
I want to change my cookie's value in javascript or html.

I want to set a cookie in 'index.html'
in javascript, I can get cookie's value as {{request.COOKIES.glob }}
and how can I change glob`s value to 1 ..

in my View.py)
response = render(request, 'index.html') response.set_cookie('glob',0) return response

I already search in google, but I can't find any answers ... please help me. t_t

M.Armoun
  • 901
  • 2
  • 11
  • 35
KunAguero
  • 45
  • 6

1 Answers1

0

I don't think it's necessary to set cookie in client side, unless for something unusual. Because you can set whatever cookie you want from server response like what you wrote in post.

But you can do it by change value of document.cookie.

document.cookie = 'glob=0';

For more information, follow this link

Reza Torkaman Ahmadi
  • 2,668
  • 2
  • 15
  • 40