nagasurendra commited on
Commit
80bae4f
·
verified ·
1 Parent(s): 85d4311

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -105,6 +105,20 @@ def order_history():
105
  print(f"Error fetching order history: {str(e)}")
106
  return render_template("order_history.html", orders=[], error=str(e))
107
  app.permanent_session_lifetime = timedelta(minutes=2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  @app.route("/dashboard")
109
  def dashboard():
110
  return render_template("dashboard.html")
 
105
  print(f"Error fetching order history: {str(e)}")
106
  return render_template("order_history.html", orders=[], error=str(e))
107
  app.permanent_session_lifetime = timedelta(minutes=2)
108
+ @app.before_request
109
+ def check_session_timeout():
110
+ if "last_activity" in session:
111
+ last_activity_time = session["last_activity"]
112
+ now = datetime.now().timestamp()
113
+
114
+ # Check if inactivity time has exceeded 5 minutes (300 seconds)
115
+ if now - last_activity_time > 300:
116
+ session.clear() # Clear session
117
+ return redirect(url_for("logout"))
118
+
119
+ # Update last activity timestamp on every request
120
+ session["last_activity"] = datetime.now().timestamp()
121
+
122
  @app.route("/dashboard")
123
  def dashboard():
124
  return render_template("dashboard.html")