It's simple. If you want to get a specific object, just add the variable name to the session, for example. session['nickname'].
You can set the variable in the same way by doing session['nickname'] = nickname.
In your case, you change it to the following
if 'user' in session:
user = session['user']
print user
if 'nickname' in session:
nickname = session['nickname']
print nickname
This is a simplified version of the function I use to login.
@app.route('/login', methods=['POST'])
def login():
"""Authenticate User"""
username = request.form['username'].strip()
nickname = request.form['nickname'].strip()
password = request.form['password']
try:
if Auth().VerifyLogin(username, password):
session['username'] = username
session['nickname'] = nickname
else:
except Exception as why:
app.logger.critical('.....')
source
share