Main concepts

Saving user selection

A bit ironically, django-cookie-consent uses a cookie itself to store the user consent. By default, the name cookie_consent is used.

An example value of such a cookie could be:

optional=-1|social=2013-06-04T03:17:01.421395Z

The meaning of this is:

  • the user declined the cookie group with varname optional

  • the user accepted the cookie group with varname social, and specifically only the cookies that were created before the stated timestamp

Caching

django-cookie-consent keeps the non-required cookie groups and cookies in cache, to avoid hitting the database for each request. By default, the default Django cache is used. You can modify this, see Settings.

Note

Django’s default cache is a local-memory cache. Cache invalidation in one wsgi-server process will not propagate to other instances/processes, so you can temporarily see inconsistent results. It’s recommended to use a shared cache like Redis/Valkey or Memcache.