Skip to main content

Use MongoDB as Django session backend

Project description

django-mongo-sessions

Forked version from django-mongo-sessions.

Explain why this fork was needed.

Features

  • fast NoSQL Django sessions backend
  • invalidation via TTL

Installation

  • Install with pip
pip install django-mongo-sessions
  • Inside settings.py
SESSION_ENGINE = 'mongo_sessions.session'

Available settings

There is two ways to setup mongodb connection at settings.py. First, if already have mongo connection, like::

import pymongo
from pymongo import MongoClient
connection = MongoClient()
MONGO_CLIENT = connection.your_database
MONGO_SESSIONS_COLLECTION = 'mongo_sessions' # default option

Second, if you need to connect to mongodb, like::

MONGO_PORT = 27017
MONGO_HOST = 'localhost'
MONGO_DB_NAME = 'test'
MONGO_DB_USER = False
MONGO_DB_PASSWORD = False
MONGO_SESSIONS_COLLECTION = 'mongo_sessions'

# all this settings are defaults, you can skip any

expireAfterSeconds index value by default is SESSION_COOKIE_AGE you can change::

MONGO_SESSIONS_TTL = 60 * 60 # one hour

be sure, that you know what are you doing with it, SESSION_COOKIE_AGE will get different expiration time

every time you change one of this values, expireAfterSeconds index will be dropped and then will be indexed with ensureIndex again, be careful here

it is good way to change expireAfterSeconds only by 1 running instance

Tests

pip install tox
tox

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-mdbsessions-0.0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_mdbsessions-0.0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file django-mdbsessions-0.0.2.tar.gz.

File metadata

  • Download URL: django-mdbsessions-0.0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for django-mdbsessions-0.0.2.tar.gz
Algorithm Hash digest
SHA256 accbc75f7f7eb9de927ed7ab3240a7675d8c5faf0ad281ed219d607d1018034f
MD5 a1e444a7ffbdd997e4271137363e0339
BLAKE2b-256 8ab932d262cc2cbfaacb93e022e1e327434129ff631f77fcf84d1eb32b9788a3

See more details on using hashes here.

File details

Details for the file django_mdbsessions-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: django_mdbsessions-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for django_mdbsessions-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c515192248b13b10612864261f2bc23e6b8943430a08f55a97ddfff350dcb907
MD5 cfad2f502b2b9e828459a1ef322788ce
BLAKE2b-256 5d51df76615cc97543f96443fa90a65ffefec2f08f9b55c42d3af33ea66d4427

See more details on using hashes here.

Supported by

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