if session.get('logged_in') is not None: # do something for logged in user return render_template('success.html') else: # do something for non-logged in user return render_template('index.html')
Give it a try, it should work.
Sorry for the late reply, but I fought for the same things, and this is the main formula.
In my scenario, I have a users table in the mysql database, with which, when a user logs in or creates an account, a session variable is created and the id set by that user.
If this user now goes to the root ('/') , the session variable is detected and success.html served.
If no value is found for session['logged_in'] than index.html , where they can create an account or log in.
source share