Read the session cookie
This commit is contained in:
parent
c9f8bfe1b8
commit
c5edd6bc68
12
server.py
12
server.py
|
@ -104,9 +104,19 @@ class HTTPRequestHandler(http.server.BaseHTTPRequestHandler):
|
||||||
print('malformed cookies')
|
print('malformed cookies')
|
||||||
|
|
||||||
if 'buranun_session' in received_cookies:
|
if 'buranun_session' in received_cookies:
|
||||||
print(received_cookies['buranun_session'].value)
|
sessionid = int(received_cookies['buranun_session'].value)
|
||||||
|
print(sessionid)
|
||||||
|
userid = session.get_userid(sessionid)
|
||||||
|
|
||||||
|
if userid is not None:
|
||||||
logged_in = True
|
logged_in = True
|
||||||
|
|
||||||
|
with database.connect() as db:
|
||||||
|
print(userid, database.get_user_info(db, userid))
|
||||||
|
|
||||||
|
else:
|
||||||
|
print('unknown session ID')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('No buranun_session')
|
print('No buranun_session')
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,6 @@ def get_userid(sessionid):
|
||||||
Returns None if no user was found"""
|
Returns None if no user was found"""
|
||||||
with sessions_lock:
|
with sessions_lock:
|
||||||
if sessionid in sessions:
|
if sessionid in sessions:
|
||||||
return sessions[sessiondid]
|
return sessions[sessionid]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue