if app.config['SESSION_COOKIE_DOMAIN'] is not None:
    return app.config['SESSION_COOKIE_DOMAIN']
if app.config['SERVER_NAME'] is not None:
    rv = '.' + app.config['SERVER_NAME'].rsplit(':', 1)[0]
How to configure a single flask application to handle multiple domains?