Custom Search

Tuesday, June 14, 2016

python django how to find user information from session key

from django.contrib.sessions.models import Session
from django.contrib.auth.models import User

session_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'

session = Session.objects.get(session_key=session_key)

uid = session.get_decoded().get('_auth_user_id')

user = User.objects.get(pk=uid)

print user.username, user.get_full_name(), user.email


No comments:

Post a Comment