title: Odd behavior with Flask App taking multiple login attempts
body: <p>I have a flask app with simple authentication that I am hosting through google cloud. I am currently testing the application by logging in and out of multiple users and I am getting some extremely weird behaviour that I wasn't previously getting. In particular, sometimes when I am logging in with a valid user account, it does nothing on the first few login attempts and then on the second or third try it will login (wtf?????). I suspect it has something to do with local storage/session storage so I am clearling local storage with session.clear() upon logging it out but it doesn't seem to be working. </p>
  
  <p>Please help me because this is killing me lol. Any help would be appreciated. </p>
  
  <p>Here is the code: main.py</p>
  
  <pre><code>from flask import Blueprint, render_template
  from flask_login import login_required, current_user
  from . import db, create_app
  
  main = Blueprint('main', __name__)
  
  @main.route('/')
  def index():
       return render_template('index.html')
  
  @main.route('/profile')
  @login_required
  def profile():
      return render_template('profile.html', name=current_user.name)
  </code></pre>
  
  <p>Here is the code auth.py</p>
  
  <pre><code>from flask import Blueprint, render_template, redirect, url_for, request, flash
  from werkzeug.security import generate_password_hash, check_password_hash
   from flask_login import login_user, logout_user, login_required
  from .models import User, Subs
  from . import db
  
  auth = Blueprint('auth', __name__)
  
  @auth.route('/login')
  def login():
     return render_template('login.html')
  
   @auth.route('/login', methods=['POST'])
   def login_post():
      email = request.form.get('email')
      password = request.form.get('password')
      remember = True if request.form.get('remember') else False
  
       user = User.query.filter_by(email=email).first()
  
       if not user and not check_password_hash(user.password, password):
          flash('Please check your login details and try again.')
           return redirect(url_for('auth.login'))
  
  login_user(user, remember=remember)
  
  return redirect(url_for('main.profile'))
  
   @auth.route('/signup')
   def signup():
       return render_template('signup.html')
  
   @auth.route('/signup', methods=['POST'])
   def signup_post():
        email = request.form.get('email')
        name = request.form.get('name')
        password = request.form.get('password')
  
        user = User.query.filter_by(email=email).first()
  
        if user:
            flash('Email address already exists.')
            return redirect(url_for('auth.signup'))
  
        new_user = User(email=email, name=name, password=generate_password_hash(password, method='sha256'))
  
     db.session.add(new_user)
     db.session.commit()
  
     return redirect(url_for('auth.login'))
  
   @auth.route('/logout')
   @login_required
   def logout():
       logout_user()
        return redirect(url_for('main.index'))
  </code></pre>