'AJAX login handler, used by both login and register to set the
user cookie and send back a redirect.'

def _login(self, responder, user, rem=None):

    c.user = user
    c.user_is_loggedin = True
    self.login(user, rem=rem)
    if (request.params.get('hoist') != 'cookie'):
        responder._send_data(modhash=generate_modhash())
        responder._send_data(cookie=user.make_cookie())
    responder._send_data(need_https=feature.is_enabled('force_https'))
