Reference¶
Middleware¶
- class user_sessions.middleware.SessionMiddleware¶
Middleware that provides ip and user_agent to the session store.
Models¶
- class user_sessions.models.Session(*args, **kwargs)¶
Session objects containing user session information.
Django provides full support for anonymous sessions. The session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server side and abstracts the sending and receiving of cookies. Cookies contain a session ID – not the data itself.
Additionally this session object providers the following properties: user, user_agent and ip.
Session Backends¶
- class user_sessions.backends.db.SessionStore(user_agent, ip, session_key=None)¶
Implements database session store.
Template Tags¶
Transform a User Agent into a human readable text.
Example output:
- Safari on iPhone
- Chrome on Windows 8.1
- Safari on OS X
Transform an IP address into an approximate location.
Example output:
- Zwolle, The Netherlands
- <i>unknown</i>
Views¶
- class user_sessions.views.SessionListView(**kwargs)¶
View for listing a user’s own sessions.
This view shows list of a user’s currently active sessions. You can override the template by providing your own template at user_sessions/session_list.html.
- class user_sessions.views.SessionDeleteView(**kwargs)¶
View for deleting a user’s own session.
This view allows a user to delete an active session. For example locking out a session from a computer at the local library or a friend’s place.
Unit tests¶
- class user_sessions.utils.tests.Client(enforce_csrf_checks=False, **defaults)¶
Custom implementation of django.test.Client.
It is required to perform tests that require to login in sites using django-user-sessions since its implementation of SessionStore has to required parameters which is not in concordance with what is expected from the original Client