By default, Flask uses volatile sessions, which means the session cookie is set to expire when browser closes. In order to use permanent sessions, which will use a cookie
I choose what you said "login_user()"
@asset.route('/login', methods=['GET', 'POST']) def login(): #After Verify the validity of username and password session.permanent = True
if it set at app.before_request, This will lead to set them too may times.