Note that there are some explanatory texts on larger screens.

plurals
  1. POIntermittently getting a scrambled CSRF cookie when using Django Admin
    primarykey
    data
    text
    <p>Using Django 1.4, I keep getting the CSRF cookie intermittently scrambled to something like this:</p> <blockquote> <p>"Set-Cookie: csrftoken=\"Set-Cookie: csrftoken=WStoUW0COc1JvURmsc0vwRgJ8uCWR5Hh\073 expires=Mon\054 26-Aug-2013 15:24:38 GMT\073 Max-Age=31449600\073 Path=/\""</p> </blockquote> <p>(Rather than, say <code>WStoUW0COc1JvURmsc0vwRgJ8uCWR5Hh</code>, which is the actual value of that CSRF cookie.)</p> <p>I seem to get that happen after reloading the Add/Edit page several times on <em>any</em> object (I've not tested them all, but I get it on custom models and on Django.auth's User). After that, even if I delete it, I almost always get it again on the next refresh.</p> <p>The content of the cookie is very reminiscent of <a href="https://code.djangoproject.com/ticket/15863" rel="nofollow noreferrer">this bug</a>, but</p> <ol> <li>It's not exactly the same, it's missing escaping</li> <li>supposed to have been fixed and</li> <li>this page in the Django admin is not cached anyway (the add/edit page as per its use of the admin_view decorator by default)</li> </ol> <p>I used to think that DajaxICE had something to do with this, but it only brought the problem to light as it would fail after the cookie was set wrongly. As indicated above, this happens on admin pages that don't and have never had DajaxICE things on them.</p> <p><strong>Update:</strong> This looks even more like what is discussed in these <a href="https://groups.google.com/forum/#!topic/django-developers/Q9zTDofY_sA" rel="nofollow noreferrer">two</a> <a href="http://python.6.n6.nabble.com/Django-1-4-bug-Using-cache-page-and-csrf-protect-decorators-results-in-a-messy-Set-Cookie-response-h-td4973973.html" rel="nofollow noreferrer">threads</a>, but even those speak of a view needing to use a TemplateResponse (check for Django Admin's add view), have csrf protection (check), and use cache_page (or I assume at least <em>some</em> form of caching - which the add view very definitely does not).</p> <p>Seeing as using django_annoying's ajax_request apparently doesn't care that this cookie is garbled (and Django Admin never did), I can continue without fixing this, but... What the?! From what I can tell, all that's required to break this is using site-wide caching and the Admin site, which is a bit ridiculous... Not to mention it's very concerning that Django Admin doesn't mind the fact there's a garbled cookie.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload