webgo/logout.py

21 lines
No EOL
547 B
Python

import database,helper
from cherrypy import cpg
from cherrypy.lib import httptools
class Logout:
def index(self):
try:
username = cpg.request.sessionMap["username"]
myuser = database.Users.byUsername(username)
myuser.sessionid = None
myuser.timeout = 0
except:
return helper.cs_render("templates/not_logged_in.cs")
username = ""
#sessionid = cpg.request.sessionMap["_sessionId"]
# now let cookie expire
cpg.response.simpleCookie["WebGoSessionCookie"]["expires"] = 0
httptools.redirect("/")
index.exposed = True