Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
def set_session_type(session, usertype):
"""
Sets the access type for the session
:param session: The session cookie for the user
:param usertype: The type of access level of the user to be set
:return: Nothing
"""
if usertype == 'admin': # if the usertype parameter is admin
session['usertype'] = 'admin' # set admin session cookies
elif usertype == 'normal': # if the usertype parameter is normal
session['usertype'] = 'normal' # set normal session cookies
def is_admin(session):
"""
Returns a boolean indicating if the user's session is an admin one.\n
Performed by checking the 'usertype' key of the session
:param session: The user's session cookie
:return: True if the user's session is an admin one, false if not.
"""
if 'usertype' not in session: # checks if the session cookie even exists
return False
if session['usertype'] != 'admin': # if the user's type is not admin
return False # user is not an admin
else: # otherwise
return True # user is an admin