def handleCheckCookieRequest(request): get = request.GET token = get.get('token') sessionId = get.get('id') cookie = models.get_cookie(sessionId, token) if cookie: loginfo('valid cookie') return HttpResponse(json.dumps({'userId': cookie.userId})) else: loginfo('invalid cookie') return HttpResponseBadRequest()
def handleLogoutRequest(request): delete = request.REQUEST token = delete.get('token') sessionId = delete.get('id') loginfo("clear cookie: ") loginfo("token: " + token) loginfo('id: ' + sessionId) cookie = models.get_cookie(sessionId, token) if cookie: cookie.delete() loginfo('cookie deleted') return HttpResponse()