Home

Awesome

Django Evercookie

Django Evercookie is an implementation of [Evercookie] (http://en.wikipedia.org/wiki/Evercookie) with Django backend services. Evecrookie core component was rebuilt to use of Django's batteries, so all configurations and hook-ups are done in plain Python and Django's templatetags.

Note: Django 1.5 or later required.

Contributions

The project hasn't been maintained for quite some time. Afaik later Django versions have some API changes that require the backend to be modified. If you want to contribute to the project and keep it up to date, please send pull requests.

Browser Storage Mechanisms Supported in Django Evercookie

Client browsers must support as many of the following storage mechanisms as possible in order for Evercookie to be effective.

External Dependencies

Is used to turn off Vary HTTP headers for some views because Django adds this headers automatically if Auth and Session middlewares are used.

To generate PNG cookies.

Installation

  1. Install Python Egg
pip install git+https://github.com/gdmka/django_evercookie.git#egg=django-evercookie
  1. Add Django Evercookie to INSTALLED_APPS
INSTALLED_APPS += ('django_evercookie',)
  1. Add RemoveUnneededVaryHeadersMiddleware at the top of MIDDLEWARE_CLASSES in settings.py:
MIDDLEWARE_CLASSES = (
    'django_dont_vary_on.middleware.RemoveUnneededVaryHeadersMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    ...
    )
  1. Add routing in urls.py
urlpatterns += patterns('', ('', include('django_evercookie.urls')),)

Basic Configuration

Sometimes you need to configure things your way. Some snippets of configuring Django Evercookie.

from django_evercookie.config import settings
#Changing cookie names for Etag storage
settings.etag_cookie_name = 'etagstorage'
#Enabling CSS History Knocking
settings.history = 'true'
#Setting Django's STATIC_URL manually
settings.static_url = '/cdn/'

Using Templatetags

Add this code to load evercookie in template and set a value.

{% load staticfiles %}
<script src="{% static 'django_evercookie/swfobject-2.2.min.js' %}"></script>
<script src="{% url 'django_evercookie.views.evercookie_core' %}"></script>
{% load evercookie_js_api %}
{% set_evercookie ec_obj='evercookie' name='dummy' value='some_value' %}

This will load evercookie core library and render set method.

<script>
var evercookie=new evercookie();
evercookie.set("dummy", "some_value");
</script>

The get method is as simple as adding

{% rediscover_evercookie ec_obj='evercookie' name='dummy' %}

to discover what was set in previous snippet.

Acknowledgement

Evercookie was developed by Samy Kamkar, with contributions from others

License

MIT