title: Flask Login sessions not persisting when page changes
body: <p>I am using flask-login, flask and socketio in python. When I log in the user as can be seen in the login_data() function the session variables are set correctly by flask-login. However when the route changes all of the session variables are lost, which causes flask login to disallow the user to access the /overview page. I have tried long and hard and cannot think why the session variables are lost, I have tried it in chrome, firefox and internet explorer, all with the same outcome.</p>
  
  <p>p.s - I know I am not hashing passwords, I will get around to that after this.</p>
  
  <p>main.py:</p>
  
  <pre><code>#Store
  from flask import *
  import nltk
  import functools
  import re
  from users import User
  #from flask_socketio import SocketIO,send,emit,disconnect
  from flask_socketio import *
  from flask_login import LoginManager,login_user,current_user,login_required
  import flask_login
  from pymongo import MongoClient
  client = MongoClient()
  db = client.database
  
  app = Flask(__name__)
  app.secret_key= 'lemon'
  socketio = SocketIO(app)
  login_manager = LoginManager()
  login_manager.init_app(app)
  
  @login_manager.user_loader
  def load_user(email):
      print('email given: '+email)
      cursor = db.users.find_one({"user.email":str(email)})
      if not cursor:
          return None
      return User(email)
  
  
  
  @app.route('/')
  def home():
      print('overview session')
      for i in session:
          print(session[i])
      return render_template('index.html')
  
  
  
  @app.route('/login')
  def login():
  
      return render_template('login.html')
  
  
  @app.route('/overview')
  @login_required
  def overview():
      return render_template('overview.html')
  
  @socketio.on('login_data')
  def login_data(email,password):
      cursor = db.users.find_one({"user.email":str(email),"user.password":str(password)})
      if cursor:
          user = User(cursor['user']['email'])
          print(user.get_id())
          login_user(user,remember=True)
          print('sessions')
          for i in session:
              print(session[i])
  
          emit('auth',[True,current_user.email])
      else:
          emit('auth',False)
  
  
  
  if __name__ == '__main__':
      socketio.run(app,host='0.0.0.0',debug=True)
  </code></pre>
  
  <p>Users Class:</p>
  
  <pre><code>#Users.py
  from pymongo import MongoClient
  class User(object):
      def __init__(self,email):
          self.email = email
  
      def is_authenticated(self):
          return True
      def is_active(self):
          return True
      def is_anonymous(self):
          return False
      def get_id(self):
          return unicode(self.email)
  </code></pre>