Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can make SESSION_SERIALIZATION_FORMAT = 'json' work #246

Open
eusoubrasileiro opened this issue May 14, 2024 · 1 comment
Open

can make SESSION_SERIALIZATION_FORMAT = 'json' work #246

eusoubrasileiro opened this issue May 14, 2024 · 1 comment

Comments

@eusoubrasileiro
Copy link

eusoubrasileiro commented May 14, 2024

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
Copy link
Contributor

Lxstr commented May 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants