Skip to content

Instantly share code, notes, and snippets.

@1stvamp
Created July 19, 2011 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1stvamp/1092652 to your computer and use it in GitHub Desktop.
Save 1stvamp/1092652 to your computer and use it in GitHub Desktop.
Re-init Django session from GET value
"""Sometimes you just want to load your session based on a GET value,
without having an entire middleware installed to do it everytime, e.g.
just do it quickly in a view.
"""
def test_view(request):
# Assuming session key sent as 'sessionid' value in querystring
request.session = request.session.__class__(session_key=request.GET['sessionid'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment