Sometimes, we want to fix secret key not set in a Python Flask session, using the Flask-Session extension.
In this article, we’ll look at how to fix secret key not set in a Python Flask session, using the Flask-Session extension.
How to fix secret key not set in a Python Flask session, using the Flask-Session extension?
To fix secret key not set in a Python Flask session, using the Flask-Session extension, we set the app.secret_key
property to the secret key.
For instance, we write
if __name__ == "__main__":
app.secret_key = 'super secret key'
app.config['SESSION_TYPE'] = 'filesystem'
sess.init_app(app)
app.debug = True
app.run()
to set app.secret_key
to the secret key when we start our app.
Then the secret key should be picked up by Flask-Session.
Conclusion
To fix secret key not set in a Python Flask session, using the Flask-Session extension, we set the app.secret_key
property to the secret key.