flask-session icon indicating copy to clipboard operation
flask-session copied to clipboard

Session not saving

Open NeuroAssassin opened this issue 5 years ago • 6 comments

Hey there. I've been using flask-session for a while now, and I have had one moderate continuous problem throughout, and with the new update, I'm having a major issue.

First, with the new update switching to cachelib, I can't set anything in session. I have a button that sends a web request to another endpoint on my site, which sets a variable in session using session['theme'], but when I reload the page, it's back to how it was.

Second, I've noticed that quite a lot, the session will just... refresh. I'll lose everything I have in my cookies, resetting my authorization and also the theme I have set, which can be real annoying.

If you could fix the above issues, or point me to what I'm doing wrong, that'd be great. If you want to take a look at the code I'm using, head to the Toxic-Cogs repo on my account, then look in dashboard\data on the dashboard-testing branch. Thanks.

NeuroAssassin avatar May 15 '20 20:05 NeuroAssassin

@NeuroAssassin this issue is because of an bug in cachelib . pallets/cachelib/pull/12. on windows cachelib set fails when the cache file already exist. it need to be fixed in cachelib by chaning os.rename to os.replace.

in cachelib the error is suppressed and instead it returned False. probably in https://github.com/fengsp/flask-session/blob/master/flask_session/sessions.py#L353 the return code needs to be checked and probably raise an exception.

snjypl avatar May 15 '20 23:05 snjypl

@snjypl Thanks for getting back. Great to know that that issue has been seen. Do you know anything about the issue with the session resetting constantly though? I was getting that before I updated.

NeuroAssassin avatar May 15 '20 23:05 NeuroAssassin

@NeuroAssassin this issue is because of an bug in cachelib . pallets/cachelib/pull/12.

That pull seems to be merged. I still have the issue. What to do?

Adityashaw avatar May 26 '20 20:05 Adityashaw

you can try installing it from git

pip install git+https://github.com/pallets/cachelib.git@master

snjypl avatar May 29 '20 18:05 snjypl

Been searching for a week to finally narrow it down to flask-session update (I was using werkzeug < 1 before v0.3.2).
Thanks for the info ! Unfortunately I think it means downgrading again in the meanwhile...

GChalony avatar Jun 01 '20 10:06 GChalony

@NeuroAssassin @snjypl @Adityashaw @GChalony

That upstream fix (https://github.com/pallets/cachelib/pull/12) was released in its 0.1.1 version 7 hours ago. And, given that flask-session currently always picks up latest version of cachelib, you should be able to update your environment and then test it out.

rayluo avatar Jun 20 '20 19:06 rayluo

Closing as fixed w/ @rayluo comment. please comment back or open a new issue if there is still problem.

christopherpickering avatar May 11 '23 16:05 christopherpickering