Django

Code

Changeset 6545

Show
Ignore:
Timestamp:
10/20/07 00:13:56 (9 months ago)
Author:
mtredinnick
Message:

Fixed #4724 -- Added support for configurable session cookie paths. Helps with
multiple Django installs under the same hostname. Thanks, frej and Graham
Dumpleton.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/conf/global_settings.py

    r6333 r6545  
    276276SESSION_COOKIE_DOMAIN = None                            # A string like ".lawrence.com", or None for standard domain cookie. 
    277277SESSION_COOKIE_SECURE = False                           # Whether the session cookie should be secure (https:// only). 
     278SESSION_COOKIE_PATH = '/'                               # The path of the session cookie. 
    278279SESSION_SAVE_EVERY_REQUEST = False                      # Whether to save the session data on every request. 
    279280SESSION_EXPIRE_AT_BROWSER_CLOSE = False                 # Whether sessions expire when a user closes his browser. 
  • django/trunk/django/contrib/sessions/middleware.py

    r6333 r6545  
    3232                    max_age = settings.SESSION_COOKIE_AGE 
    3333                    rfcdate = formatdate(time.time() + settings.SESSION_COOKIE_AGE) 
    34                      
     34 
    3535                    # Fixed length date must have '-' separation in the format 
    3636                    # DD-MMM-YYYY for compliance with Netscape cookie standard 
     
    4040                # Save the seesion data and refresh the client cookie. 
    4141                request.session.save() 
    42                 response.set_cookie(settings.SESSION_COOKIE_NAME, request.session.session_key, 
    43                     max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN, 
    44                     secure=settings.SESSION_COOKIE_SECURE or None) 
    45                      
     42                response.set_cookie(settings.SESSION_COOKIE_NAME, 
     43                        request.session.session_key, max_age=max_age, 
     44                        expires=expires, domain=settings.SESSION_COOKIE_DOMAIN, 
     45                        path=settings.SESSION_COOKIE_PATH, 
     46                        secure=settings.SESSION_COOKIE_SECURE or None) 
     47 
    4648        return response 
  • django/trunk/docs/settings.txt

    r6534 r6545  
    476476 
    477477List of locations of the fixture data files, in search order. Note that 
    478 these paths should use Unix-style forward slashes, even on Windows. See  
     478these paths should use Unix-style forward slashes, even on Windows. See 
    479479`Testing Django Applications`_. 
    480480 
     
    732732Default: Not defined. 
    733733 
    734 A dictionary of modules containing serializer definitions (provided as  
    735 strings), keyed by a string identifier for that serialization type. For  
     734A dictionary of modules containing serializer definitions (provided as 
     735strings), keyed by a string identifier for that serialization type. For 
    736736example, to define a YAML serializer, use:: 
    737737 
     
    755755Controls where Django stores session data. Valid values are: 
    756756 
    757     * ``'django.contrib.sessions.backends.db'``       
    758     * ``'django.contrib.sessions.backends.file'``     
     757    * ``'django.contrib.sessions.backends.db'`` 
     758    * ``'django.contrib.sessions.backends.file'`` 
    759759    * ``'django.contrib.sessions.backends.cache'`` 
    760      
     760 
    761761See the `session docs`_ for more details. 
    762762 
     
    784784The name of the cookie to use for sessions. This can be whatever you want. 
    785785See the `session docs`_. 
     786 
     787SESSION_COOKIE_PATH 
     788------------------- 
     789 
     790Default: ``'/'`` 
     791 
     792The path set on the session cookie. Should match the URL path of your Django 
     793installation (or be parent of that path). This is useful if you have multiple 
     794Django instances running under the same hostname; they can use different 
     795cookie paths and each instance will only see its own session cookie. 
    786796 
    787797SESSION_COOKIE_SECURE