Created
July 30, 2014 13:16
-
-
Save turtlemonvh/48d92d4153754aea4504 to your computer and use it in GitHub Desktop.
Middleware for running django on multiple ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
class MultiPortMiddleware(object): | |
""" | |
Middleware changes the SESSION_COOKIE_NAME to use the current port in the name | |
""" | |
def process_request(self, request): | |
settings.SESSION_COOKIE_NAME = 'sessionid' + request.META['SERVER_PORT'] | |
return None |
Thanks @MonsieurV, that solution looks better. Updating a global setting in each request was clearly not a good idea!
How to store the session in Django between two different ports and we are using IP not domain. here one server is Django and another server is angular.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An alternative that only change the cookie name used in the middleware, without modifying any global setting (which may have side effects).
https://gist.github.com/MonsieurV/c2637d959ccd9d8e962a3ac453daed83