Answer the question
In order to leave comments, you need to log in
Is it possible to have the same sessions on two sites?
The hosts file is set to:
127.0.0.1 one.ru
127.0.0.1 two.ru I start
the project:
python manage.py runserver 80
Both sites are successfully picked up and working.
Created MIDDLEWARE:
from django.urls import set_urlconf
class SimpleMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
# One-time configuration and initialization.
def __call__(self, request):
# Code to be executed for each request before
# the view (and later middleware) are called.
host = request.get_host()
if host == 'one.ru':
set_urlconf('one.urls')
request.urlconf = 'one.urls'
elif host == 'two.ru':
set_urlconf('two.urls')
request.urlconf = 'two.urls'
response = self.get_response(request)
# Code to be executed for each request/response after
# the view is called.
host = request.get_host()
return response
request.session.q = 5
Answer the question
In order to leave comments, you need to log in
Both sites should store sessions together and transfer you to each other (additional cookie, intermediary service). It is similarly implemented here - transparent authorization through TM
If they simply store session files in a shared storage - when visiting sites - 2 different sessions will be generated
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question