title: Flask.session persisting after close browser
body: <p>I want to be able to detect if a user has closed a browser since last logging into a Flask site. I have read that Flask sessions are supposed to expire on closing the browser, but the session data is stored on the server as far as I can tell and is persisting across browser sessions. How can I clear all session data when the user closes the browser?</p>
  
  <p>mainapp.py:</p>
  
  <pre><code>@mainapp.route('/')
  def home():
      if 'user_name' in session:
          logger.debug( 'Logged in as {0}'.format(escape(session['user_name'])))
      return render_template('home.html')
  </code></pre>
  
  <p>userviews.py:</p>
  
  <pre><code>@userviews.route("/login", methods=["GET", "POST"])
  def login():
      form = LoginForm(request.form)
      if form.validate_on_submit():
          #get user from db
          session['user_name'] = user.user_name
  </code></pre>
  
  <p>setup.py:</p>
  
  <pre><code>app.secret_key = 'somethingreallysecret'
  </code></pre>