Skip to main content

Stores the user's information in the session, reucing database queries by a lot.

Project description

===================
django-session-user
===================

This app is a simple piece of middleware that can be added to your Django
project which will store and retrieve the logged-in user's information from
the session.


Installation
------------

Add the sesionuser middleware line to your MIDDLEWARE_CLASSES after the
AuthenticationMiddleware:

MIDDLEWARE_CLASSES = (
# ...
'django.contrib.auth.middleware.AuthenticationMiddleware',
'sessionuser.middleware.UserSessionMiddleware',
# ...
)


Why do this?
------------

Your server is already fetching the contents of the user's session, which
already contains the user's identity. Why not store the rest of the user
class's data along with it? That way you don't have to make a request to the
database for every authenticated web request.

Additionally if you are using a cookie-based session backend (like
django-cookie-sessions, written by yours truly) you can have other systems,
maybe even non-Django systems, which read the cookie and know more information
about the user.


Customizable Settings
---------------------

COOKIE_USER_REFRESH_TIME [= 14400]:

The number of seconds that need to elapse before the user is fetched from
the database instead of trusting the cookie. This is useful for making
sure that even if the user's properties are changed in the database,
the user's cookie will still be updated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-session-user-0.1.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file django-session-user-0.1.tar.gz.

File metadata

File hashes

Hashes for django-session-user-0.1.tar.gz
Algorithm Hash digest
SHA256 bc9f8850b6aaeb05b858f9cf10e19bc626fa70d31800faf4c57f4c3a825468e0
MD5 88b82e52e84048122b1ce47ea8b69ab1
BLAKE2b-256 b28fd5ee87d19380f45da9c556c4454a69ef36baa09213b99d12477c7cd306a2

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page