Skip to content

Instantly share code, notes, and snippets.

View leohemsted's full-sized avatar
🚴

Leo Hemsted leohemsted

🚴
View GitHub Profile
@glarrain
glarrain / gist:3982485
Created October 30, 2012 19:37
Decode session data, no matter what hashes say. It helps in some cases where the Session.get_decoded method returns an empty dictionary because it is "suspicious" of user-data tampering. Based on source code from the Django project.
import base64
import pickle
from django.contrib.sessions.models import Session
from django.utils.encoding import force_unicode
def decode_session_data(session_key):
"""Decode the data in a session object stored under ``session_key``.