Search code examples
pythonpython-3.xflaskflask-session

Flask : session not working. Showing session object has no attribute 'modified'


I'm trying to pass a list of dictionaries between Flask pages through session but it is giving me this error enter image description here

I have an __init__.py file inside a package flaskapp that imports all the modules I created and runs app = Flask(__name__)

from flask import Flask

app = Flask(__name__)
from flaskapp import api_views
from flaskapp import admin_views
from flaskapp import utilities
from flaskapp import firebase_admin_views

and doing this inside my admin_views.py

from flask import session
from flaskapp import app

app.config["SECRET_KEY"] = 'secret key'
app.config["SESSION_TYPE"] = 'filesystem'

@app.route('/get/result',methods=["GET", "POST"])
def get_result():
    '''
        Code to process my data
    '''
    session['DICT_DATA'] = dict_data

@app.route('/get/result/download',methods=["GET", "POST"])
def get_result():
    dict_data = session['DICT_DATA']

Can anyone please tell me why is this happening


Solution

  • I was using " (double quotes) instead of ' (single quote) in session["DICT_DATA"] = dict_data

    You should be using ' (Single quote) to create session.