'Either sets the cookie with the encoded data if there is any data to
store, or deletes the cookie.'

def _update_cookie(self, encoded_data, response):

    if encoded_data:
        response.set_cookie(self.cookie_name, encoded_data, domain=settings.SESSION_COOKIE_DOMAIN)
    else:
        response.delete_cookie(self.cookie_name, domain=settings.SESSION_COOKIE_DOMAIN)
