def login_with_permission_from_post(login_decorator=login_and_domain_required):
    def view_decorator(view_func):
        def new_view(req, domain, *args, **kwargs):
            if req.method == 'POST':
                cookie = req.POST.get('_cookie')
                if cookie:
                    cookies = dict(map(lambda x: x.strip().split('=', 1), cookie.split(';')))

                    session_key = cookies.get(settings.SESSION_COOKIE_NAME, None)
                    engine = import_module(settings.SESSION_ENGINE)
                    req.session = engine.SessionStore(session_key)

                    req.user = get_user(req)
                    req.couch_user = CouchUser.from_django_user(req.user)
            return login_decorator(view_func)(req, domain, *args, **kwargs)
        return new_view
    return view_decorator
This sets user and couch_user in the request from a cookie passed in the POST variables.
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/hqmedia/decorators.py/login_with_permission_from_post