3

Following this tutorial piece from here:

@app.route('/')
def index():
    if 'username' in session:
        return 'Logged in as %s' % escape(session['username'])
    return 'You are not logged in'

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        session['username'] = request.form['username']
        return redirect(url_for('index'))
    return '''
        <form action="" method="post">
            <p><input type=text name=username>
            <p><input type=submit value=Login>
        </form>
    '''

I cannot seem to get this working on Chromium browser. Seems like the session is not being saved and even with session.modified = True it does not persist to index route. In other words - the session cookie is not being created.

Chromium version: 54.0.2840.71
Tested working on Firefox and Qutebrowser browsers.

Granitosaurus
  • 20,530
  • 5
  • 57
  • 82
  • to find out its a chromium side problem, check developer console of chromium browser ( F12 ) & network tab; check the response header contains atlease "Set-Cookie" – Renjith Thankachan Dec 05 '16 at 09:38
  • tested on MacOS El Capitan with Chrome 54.0.2840.98 and on Linux(Ubuntu 16.04) with chromium 56.0.2924.14 (chrome-dev) without any problem. You might have a strange setting on your chrome about sessions or try updating chromium – Gerard Rozsavolgyi Dec 05 '16 at 10:03
  • Do you have any other routes defined? It may be related to favicon.ico. See http://stackoverflow.com/questions/2953536/randomly-losing-session-variables-only-in-google-chrome-url-rewriting – Kevin Schellenberg Dec 05 '16 at 14:00

1 Answers1

3

It is to late do add something in this post? I hope not.

I've been fought this problem for a week and find out that is possible to create session in the Chrome browser using IP.

My config file has these configurations:

    SERVER_NAME = '192.168.0.6:5000'
    SESSION_COOKIE_NAME = '192.168.0.6:5000'
    SESSION_COOKIE_DOMAIN = '192.168.0.6:5000'

It allowed me to use a local virtual machine and the cookie worked perfectly on Chrome, without the need o a local FQDN.

In my case the problem was that the Chrome and Chromium did not create a cookie to connect with the server session.

DPalharini
  • 413
  • 6
  • 16