Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask session and multiple users

@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?

like image 916
garoo Avatar asked Jan 26 '17 03:01

garoo


People also ask

Is Flask session unique for each user?

Sessions in Flask are cookie-based, meaning that is not necessarily IP/user/request based unless you develop the server logic in this way. The fact that sessions are cookies based allows the user to read the content, so be aware of what you put there.

Can Flask handle multiple users?

As of Flask 1.0, flask server is multi-threaded by default. Each new request is handled in a new thread. This is a simple Flask application using default settings.

How are sessions managed in Flask?

The data that is required to be saved in the Session is stored in a temporary directory on the server. The data in the Session is stored on the top of cookies and signed by the server cryptographically. Each client will have their own session where their own data will be stored in their session.

How many sessions are in a Flask?

The series was renewed for a ninth and final season in March 2022. As of June 29, 2022, 171 episodes of The Flash have aired, concluding the eighth season.


1 Answers

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

like image 149
Efthyvoulos Tsouderos Avatar answered Oct 27 '22 21:10

Efthyvoulos Tsouderos