Browse Source

try make the session permanent

Karl Hudgell 3 weeks ago
parent
commit
873525d9e0
1 changed files with 9 additions and 0 deletions
  1. 9 0
      app.py

+ 9 - 0
app.py

@@ -17,6 +17,15 @@ app.config.from_object(
 ) 
 cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
 
+app.config['SESSION_COOKIE_SECURE'] = True  # Only send cookie over HTTPS
+app.config['SESSION_COOKIE_HTTPONLY'] = True  # Prevent JavaScript access
+app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'  # Adjust for cross-site requests
+app.config['PERMANENT_SESSION_LIFETIME'] = 60 * 60 * 24 * 365  # 1 year in seconds
+
+@app.before_request
+def make_session_permanent():
+    session.permanent = True
+
 @app.route('/manifest.json')
 def serve_manifest():
     return send_file('manifest.json', mimetype='application/manifest+json')