title: Flask logout user when session expires
body: <p>Is there a way to execute a logout_user when a session expires? I'm using Flask-Login and have a method that sets permanent session lifetime to 10 minutes.
  In my case I would like to logout a user on session expiration.</p>
  
  <pre class="lang-py prettyprint-override"><code>@app.before_request
  def make_session_permanent():
      session.permanent = True
      app.permanent_session_lifetime = timedelta(minutes=10)
  </code></pre>