From Flask's documentation, I have the following in my config:
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5
WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi
<Directory /var/www/yourapplication>
WSGIProcessGroup yourapplication
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
In my .wsgi file, I import the proper python file and import the flask app as application. Everything works fine, but I added logging to that file because I suspected something was wrong. Apparently, that wsgi file gets called every so often whenever a browser makes connection. It restarts the app (or at least a new process). I never noticed this, nor did I see it as a problem until I imported flask-login to manage authenticated sessions. Now whenever I login, after some short time, the wsgi app is reloaded and the session history no longer exists. In effect, I have to login every few seconds. Is this the intended way mod_wsgi works? I've tested my flask app running in standalone mode (flask's own devel server) and it works flawlessly.
In a way it's a duplicate, but it's also not. The server code isn't buggy. It's just mod_wsgi restarts the application over and over. Thanks for linking to the other post, though!