Skip to content

Commit

Permalink
add parameter to set session cookie domain
Browse files Browse the repository at this point in the history
  • Loading branch information
smorrison committed Oct 15, 2019
1 parent 5bc5d04 commit 0dc8c1d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gluon/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ def connect(self,
check_client=False,
cookie_key=None,
cookie_expires=None,
compression_level=None
compression_level=None,
cookie_domain=None
):
"""
Used in models, allows to customize Session handling
Expand All @@ -766,6 +767,7 @@ def connect(self,
check_client: if True, sessions can only come from the same ip
cookie_key(str): secret for cookie encryption
cookie_expires: sets the expiration of the cookie
cookie_domain: sets the cookie domain attribute
compression_level(int): 0-9, sets zlib compression on the data
before the encryption
"""
Expand All @@ -782,6 +784,7 @@ def connect(self,
response.session_cookie_expires = cookie_expires
response.session_client = str(request.client).replace(':', '.')
response.session_cookie_key = cookie_key
response.session_cookie_domain = cookie_domain
response.session_cookie_compression_level = compression_level

# check if there is a session_id in cookies
Expand Down Expand Up @@ -1082,6 +1085,8 @@ def _try_store_in_cookie(self, request, response):
rcookies.pop(name, None)
rcookies[name] = value
rcookies[name]['path'] = '/'
if response.session_cookie_domain:
rcookies[name]['domain'] = response.session_cookie_domain
expires = response.session_cookie_expires
if isinstance(expires, datetime.datetime):
expires = expires.strftime(FMT)
Expand Down

0 comments on commit 0dc8c1d

Please sign in to comment.