class CookielessSessionPreMiddleware(object): def process_request(self, request): if not request.COOKIES.has_key('sessionid'): value = None if hasattr(request, 'POST') and request.POST.has_key('sessionid'): value = request.POST['sessionid'] elif hasattr(request, 'GET') and request.GET.has_key('sessionid'): value = request.GET['sessionid'] if value: request.COOKIES['sessionid'] = value class CookielessSessionPosMiddleware(object): def __init__(self): self._re_links = re.compile(']*)href="(/[^"]*)"([^>]*)>', re.I) self._re_forms = re.compile('', re.I) self._re_endbody = re.compile('' % \ (m.group(1), self._prepare_url(m.group(2)), sessionid, m.group(3)) response.content = self._re_links.sub(new_url, response.content) # Add a hidden input to every form with the sessionid repl_form = '' + \ '' repl_form = repl_form % (sessionid,) response.content = self._re_forms.sub(repl_form, response.content) # Add the sessionid as a javascript variable to the end of the # document repl_endbody = '