[Python] 'Flask' object has no attribute 'session_cookie_name'

Discussão em 'Python' iniciado por Stack, Julho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I keep getting the error 'Flask' object has no attribute 'session_cookie_name' right at initialization on an app that used to work.

    I built a smaller test app to test it and noticed that if I remove the line app.config["SESSION_TYPE"] = "filesystem" the error goes away. Problem is I need to use sessions in my Flask app and, since it is for testing, I would prefer to use the filesystem to store session data. here is my mini program for testing... I don't know what I am missing, this used to work fine and code examples online do it exactly this way but I keep getting the same error.

    This is the error I receive

    from flask import Flask, render_template,redirect, url_for, request, session
    from flask_session import Session

    app = Flask(__name__)

    app.config["SESSION_PERMANENT"] = False
    app.config["SESSION_TYPE"] = "filesystem"

    Session(app)

    @app.route("/")
    def index():
    session["test"] = "test"
    return render_template ('index.html')


    This worked before. It is all of the sudden not working. I have tried installing a different version of Flask_Session. I have tried adding the "SESSION_COOKIE_NAME" to app.config before Session(app) even though I understand its default is session. Nothing so far has worked or changed the error message.

    Continue reading...

Compartilhe esta Página