Skip to main content

Add the auth_remember authentication backend to django:

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'auth_remember.backend.AuthRememberBackend',
)

Add the remember middleware in your settings, right after AuthenticationMiddleware:

MIDDLEWARE_CLASSES = (
    ...
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'auth_remember.middleware.AuthRememberMiddleware',
    ...
)

Add auth_remember to INSTALLED_APPS:

INSTALLED_APPS = (
    'auth_remember',
)

Set the cookie name and expire time (optional):

AUTH_REMEMBER_COOKIE_NAME = 'remember_token'
AUTH_REMEMBER_COOKIE_AGE = 86400 * 28  # 4 weeks by default

Set the expire time of the session to browser close (optional):

SESSION_EXPIRE_AT_BROWSER_CLOSE = True

To remember a user add the following code to your authentication handler:

from auth_remember import remember_user
remember_user(request, user)

Use the user.is_fresh attribute to test if the user is fresh:

{% if user.is_fresh %}
    This user session is fresh
{% else %}
    This user session is NOT fresh
{% endif %}

Under the hood auth_remember uses the session var AUTH_REMEMBER_FRESH to indicate if the user session is fresh. The name of the session var can be changed by setting the AUTH_REMEMBER_SESSION_KEY in you’re settings file.

More information

See:

TODOs

  • Introduce settings for AUTH_REMEMBER_COOKIE_DOMAIN

Metadata

Release files for django-auth-remember 0.3

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-auth-remember 0.3
File Size Uploaded Provenance Actions
django-auth-remember-0.3.tar.gz 7.7 kB Without provenance Details for django-auth-remember-0.3.tar.gz

Release files / django-auth-remember-0.3.tar.gz

Download URL django-auth-remember-0.3.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cdf2fddc0cc632344232e225b5379d6485cfe1b09aa9116d24b3843fd71c4bfe
BLAKE2b-256 checksum
How to use checksums
8cb62d3221324372058901643ab03e9eeeea42e35c6ebb58f105634ba4b89997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-auth-remember 0.3

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.

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file No provenance

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