middleware.py 377 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
import re

class StripPiwikCookieMiddleware(object):
    # idea from http://djangosnippets.org/snippets/1772/
    strip_re = re.compile(r'(_pk_[a-z0-9\.]+=.+?(?:; |$))')
    def process_request(self, request):
        try:
            cookie = self.strip_re.sub('', request.META['HTTP_COOKIE'])
            request.META['HTTP_COOKIE'] = cookie
        except:
            pass