Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Django User Sessions

Build Status

Django includes excellent built-in sessions, however all the data is hidden away into a base64 encoded data string. This makes it very difficult to run a query on all active sessions for a particular user. Django User Sessions fixes this and makes session objects just as queryable as other objects.

To get the list of a user’s sessions:

user.session_set.filter(expire_date__gt=now())

Or logout the user everywhere:

user.session_set.all().delete()

The user’s IP address and user agent are also stored on the session. This allows to show a list of active sessions to the user in the admin:

http://i.imgur.com/YV9Nx3f.png

And also in a custom layout:

http://i.imgur.com/d7kZtr9.png

Installation

  1. pip install django-user-sessions

  2. In INSTALLED_APPS replace 'django.contrib.sessions' with 'user_sessions'.

  3. In MIDDLEWARE_CLASSES replace 'django.contrib.sessions.middleware.SessionMiddleware' with 'user_sessions.middleware.SessionMiddleware'.

  4. Add SESSION_ENGINE = 'user_sessions.backends.db'.

  5. Run python manage.py syncdb and start hacking!

GeoIP

You need to setup GeoIP for the location detection to work. See the Django documentation on installing GeoIP.

Demo application

Also, have a look at the demo application. It includes template examples and shows how to use the session list and delete views.

Compatibility

Tested on Django 1.6 with Python 2.7 and 3.3. However it should work fine on Django 1.4 and above.

Contributing

  • Fork the repository on GitHub and start hacking

  • Send a pull request with your changes

Metadata

Release files for django-user-sessions 0.1.0-beta

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-user-sessions 0.1.0-beta
File Size Uploaded Provenance Actions
django-user-sessions-0.1.0-beta.tar.gz 6.3 kB Without provenance Details for django-user-sessions-0.1.0-beta.tar.gz

Release files / django-user-sessions-0.1.0-beta.tar.gz

Download URL django-user-sessions-0.1.0-beta.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1891ceda055d5af90d77a8d71df2759879a42c9059fb9014e846999ad7886870
BLAKE2b-256 checksum
How to use checksums
5dd3daa09648bedd59de2dfb9cda824a889f4dfe75384c0812e3ded6d7c6ac2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-user-sessions 0.1.0-beta

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page