Created
September 16, 2015 14:28
-
-
Save eugena/6ea6e82e11d21869ad7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import importlib | |
from django.conf import settings | |
from django.contrib.auth import SESSION_KEY | |
def get_id_by_session_key(session_key): | |
""" | |
Returns user identifier by session_key | |
""" | |
session_store_module = importlib.import_module(settings.SESSION_ENGINE) | |
store = session_store_module.SessionStore(session_key=session_key) | |
return User._meta.pk.to_python(store[SESSION_KEY]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment