pallets-eco / flask-session

Server side session extension for Flask
https://flask-session.readthedocs.io
BSD 3-Clause "New" or "Revised" License
488 stars 236 forks source link

can make `SESSION_SERIALIZATION_FORMAT` = 'json' work #246

Open eusoubrasileiro opened 1 month ago

eusoubrasileiro commented 1 month ago

I'm using the following code to try to make SESSION_SERIALIZATION_FORMAT generate 'json' like data on the session folder. Unfornutatelly the session files generated there are binary no json readable. This is my code based on the docs

from flask import Flask, session
from flask_session import Session
from cachelib.file import FileSystemCache

app = Flask(__name__)
app.config['SESSION_TYPE'] =  'cachelib'
app.config['SESSION_SERIALIZATION_FORMAT'] = 'json'
app.config['SESSION_CACHELIB'] = FileSystemCache(threshold=500, 
    cache_dir=pathlib.Path.home() / pathlib.Path(".workapp/session") 
Session(app)

I'm using Python3.10

Lxstr commented 1 month ago

Hi there sorry for the late response. There are some possible reasons.

Technically I think in cachlib situation it is JSON within a file so it depends how you are viewing the file. If your IDE won’t view it you can try using redis or memcach locally.

Also if you have previous sessions existing they will be in the old format until you modify view the session object.

If there is still an issue when you use redis please let me know