Skip to content

Commit

Permalink
Fix unicode session behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Zaccardi committed Apr 27, 2016
1 parent 46ec8ab commit c0162a1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions flask_session/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:license: BSD, see LICENSE for more details.
"""
import time
import sys
from datetime import datetime
from uuid import uuid4
try:
Expand Down Expand Up @@ -446,7 +447,7 @@ class Session(self.db.Model):

id = self.db.Column(self.db.Integer, primary_key=True)
session_id = self.db.Column(self.db.String(256), unique=True)
data = self.db.Column(self.db.Text)
data = self.db.Column(self.db.LargeBinary)
expiry = self.db.Column(self.db.DateTime)

def __init__(self, session_id, data, expiry):
Expand Down Expand Up @@ -484,12 +485,8 @@ def open_session(self, app, request):
self.db.session.commit()
saved_session = None
if saved_session:
try:
val = saved_session.data
data = self.serializer.loads(str(val))
return self.session_class(data, sid=sid)
except:
return self.session_class(sid=sid)
data = self.serializer.loads(saved_session.data)
return self.session_class(data, sid=sid)
return self.session_class(sid=sid)

def save_session(self, app, session, response):
Expand Down

0 comments on commit c0162a1

Please sign in to comment.