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

Having issues with loading session using sqlalchemy backend

Open markosski opened this issue 10 years ago • 2 comments

I noticed there was a fix added for Python 3 to the way session string is handled but I'm still having problems. data = self.serializer.loads(want_bytes(val)) When this line executes in open_session I'm still not getting my session back. I poked around I noticed pickle is raising exception of type _pickle.UnpicklingError with no message to it.

Python 3.4.0 SQLAlchemy 0.9.8 + MySQL 5.5 Flask 0.10.1

markosski avatar Oct 28 '15 14:10 markosski

In order to make it work I had to do the following changes.

  • in class Session data column was changed to data = self.db.Column(self.db.BLOB)
  • in open_session method unserializing changed to data = self.serializer.loads(val)
  • in open_session when testing for expiration added test for existence of vlaue if saved_session and saved_session.expiry != None and saved_session.expiry <= datetime.utcnow(): This is because upon calling session.clear() in application self.get_expiration_time(app, session) returns None and expiry will be set to Null in database.

markosski avatar Oct 30 '15 14:10 markosski

This issue was moved to mcrowson/flask-session#8

mcrowson avatar Feb 12 '17 00:02 mcrowson

Fixed post 0.6.0

Lxstr avatar Feb 26 '24 04:02 Lxstr