[Python] Flask session don't persist data

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Javascript application and a Flask application. When the user send data from Js to Flask, I store it on session and it works fine at a specific route:

    @app.route(...)
    def user(...):
    session['name'] = name

    print(session['name']) # Works !


    But when I tr to get the values on session from another method / route the session is empty:

    @app.route(...)
    def current():
    print(session.keys(), session.values) # Empty !


    I have installed Flask Session and set the config to:

    'SECRET_KEY': b'...',

    'SESSION_TYPE': 'filesystem', # Memcache, null and redis

    'SESSION_PERMANENT': False, # True


    And then started the Flask application and it not work. I have also try to set session.modified = True after I add some new value to session and still not work.

    I have read lots of threads on Stack Over Flow, Reddit, etc; and nothing worked. Tips please ?

    Continue reading...

Compartilhe esta Página