10
@app.route('/login', methods = ['GET', 'POST'])
def login():
   if request.method == 'POST':
      session['username'] = request.form['username']
      return redirect(url_for('index'))
   return '''

This is the "template" for a flask session login. My question is,

'username'

is mapped to only one value which is the request.form['username']

So what if I have two users login,

(1) 'jack' 

So now session['username'] = jack

And then

(2) 'davis'

So now session['username'] = davis

But then jack is not logged in anymore. How do I do this?

garoo
  • 163
  • 1
  • 2
  • 10

4 Answers4

1

It works. Just test the users (sessions) with at least one user opened in an incognito browser window.

0

We can use dictionary to keep separate variables and session for different users eg - >Demo Code

0

Instead of incognito I use gologin profiles. In their app it is comfortable to view the saved cookies of different browser instances. It works.

-1

Edited

Flask session allows only one user to be logged in, but you can test your app with many users using following ways (there are some more though):

  • use incognito tab, but allows only 2 users to be logged in simultaneously

If you want 3 or more users:

  • use container tabs in Firefox

  • install MultiLogin extension or any other similar extension for multiple sessions, if you use Google Chrome for example or any other popular browser