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

Fix unicode session behavior #1

Open
wants to merge 1 commit into
base: 0.3-maintenance
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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