1. mirror
  2. flask


Armin Ronacher  committed 6bd0080

Added workaround for Chrome cookies

  • Participants
  • Parent commits 6ab569b
  • Branches master

Comments (0)

Files changed (2)


View file
  • Ignore whitespace
   cause caching.
 - Flask will no longer invoke the wrong error handlers if a proxy
   exception is passed through.
+- Added a workaround for chrome's cookies in localhost not working
+  as intended with domain names.
 Version 0.9

File flask/sessions.py

View file
  • Ignore whitespace
             return app.config['SESSION_COOKIE_DOMAIN']
         if app.config['SERVER_NAME'] is not None:
             # chop of the port which is usually not supported by browsers
-            return '.' + app.config['SERVER_NAME'].rsplit(':', 1)[0]
+            rv = '.' + app.config['SERVER_NAME'].rsplit(':', 1)[0]
+            # Google chrome does not like cookies set to .localhost, so
+            # we just go with no domain then.  Flask documents anyways that
+            # cross domain cookies need a fully qualified domain name
+            if rv == '.localhost':
+                rv = None
+            return rv
     def get_cookie_path(self, app):
         """Returns the path for which the cookie should be valid.  The