Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flask-login session gets destroyed on every apache restart

I am using flask-login https://github.com/maxcountryman/flask-login and the field remember in login_user does not seem to work.

The session gets destroyed after every restart of the apache ..ideally the remember field should take care of this.. even the session values gets destroyed. this is really frustrating... anyone knowing the solution please ping .. thanks i am using login_user as

login_user(user, remember=True)
like image 772
Anurag Avatar asked Dec 01 '25 02:12

Anurag


2 Answers

If anyone is suffering with this problem, you have to write the function user_loader properly.

@login_manager.user_loader
def load_user(id):
    return "get the user properly and create the usermixin object"
like image 106
Anurag Avatar answered Dec 02 '25 17:12

Anurag


I ran into this issue, but it was because we were setting Flask.secret_key to a new GUID on startup. We moved this to a configuration file (unique ID per environment) and now the session is persisted.

like image 28
mdickin Avatar answered Dec 02 '25 17:12

mdickin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!