Skip to content

Commit e609084

Browse files
Initial readme
1 parent 09165cb commit e609084

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# django-shared-session
2+
3+
django-shared-session is a tool that enables session sharing across multiple domains.
4+
It can be used even for situations where Single sign-on (SSO) is not suitable, e.g.: sharing session data of anonymous users.
5+
6+
This project is inspired by [django-xsession](https://github.com/badzong/django-xsession), but uses a different approach to session sharing
7+
which sets the cookie on server-side and thus does not require reloading the page.
8+
9+
## Installation
10+
11+
```sh
12+
pip install django-shared-session
13+
```
14+
15+
This tool uses request inside template, so please make sure you have enabled `RequestContext` in your template engine context processors.
16+
17+
## Usage
18+
Add `shared_session` to `INSTALLED_APPS` and set shared session domains in Django settings file.
19+
Then add `shared_session.urls` to your urlconf.
20+
21+
settings.py:
22+
```py
23+
INSTALLED_APPS = [
24+
'django.contrib.admin',
25+
'django.contrib.auth',
26+
# ...
27+
'shared_session'
28+
]
29+
30+
SHARED_SESSION_SITES = ['www.example.com', 'www.example.org']
31+
```
32+
33+
urls.py:
34+
```py
35+
import shared_session
36+
37+
urlpatterns = [
38+
url(r'^shared-session/', shared_session.urls), # feel free to change the base url
39+
]
40+
```
41+
42+
In order to share sessions with configured sites you also need to use `{% shared_session_loader %}` in your base template.
43+
44+
layout.html:
45+
```html
46+
{% load shared_session %}
47+
48+
<!DOCTYPE html>
49+
<html lang="en">
50+
<head>
51+
<meta charset="UTF-8">
52+
{% shared_session_loader %}
53+
</head>
54+
<body>
55+
56+
</body>
57+
</html>
58+
```
59+
60+
If you want to share sessions also in Django admin interface, you can overwrite `admin/base_site.html` and include the loader.
61+
62+
## License
63+
64+
This software is licensed under MPL 2.0.
65+
66+
- http://mozilla.org/MPL/2.0/
67+
- http://www.mozilla.org/MPL/2.0/FAQ.html#use

0 commit comments

Comments
 (0)