I want to show different header for person with logged in and person who logged out in Flask. Could I use the session variable directly in the jija2 template.
I have used different name for session since , another session variable name used for sqlalchamy session.
from flask import session as usersession
I have tried accessing the usersession variable but it's saying undefined. but when I use the session['username']
I could access the session variable.
further when I pop from usersession It's not popping from the session. Still session accessed in the tamplete has the username
variable
usersession.pop('email', None)
usersession.pop('type', None)
jinja2.exceptions.UndefinedError: 'usersession' is undefined
My code is below .
{% if usersession['username'] is not none %}
{% include "store/headers/loginheader.html" %}
{% else %}
{% include "store/headers/logoutheader.html" %}
{% endif %}