One of the things you need to do as a developer of the application is track who is logged in to your application so you can display pages related to that specific user. In Flask you can use sessions for this, first, you would need to configure your flask application:

from flask import Flask, session
from flask_session import Session

# Configure session to use filesystem
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"

Then in your application, you would need to store desired information, for example here we storing user id retrieved from the database:

session["user_id"] = db.execute("SELECT id FROM users WHERE username = :username", {"username": username}).fetchone()

Once we store it, we can retrieve the user_id, whenever there is a need for that:


And if for some reason our user logout from the app we would need to make sure, the session is cleared: