session timeout 20 minutes, for testing use 10 seconds (or less) ;-)

alphons <alphons@heijden.com> 20 Jan 2025, 10:14
11995e4260122601539415c8d6b65fa8e6986465
2 files changed
  • SessionScoped/SessionScopedFactory.cs
  • SessionScopedTest/Program.cs
diff --git a/SessionScoped/SessionScopedFactory.cs b/SessionScoped/SessionScopedFactory.cs
index dd5fc2a..14aa367 100644
--- a/SessionScoped/SessionScopedFactory.cs
+++ b/SessionScoped/SessionScopedFactory.cs
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Collections.Concurrent;
+using System.Threading;
namespace Microsoft.Extensions.DependencyInjection;
diff --git a/SessionScopedTest/Program.cs b/SessionScopedTest/Program.cs
index 0cdb5cc..f35cfbb 100644
--- a/SessionScopedTest/Program.cs
+++ b/SessionScopedTest/Program.cs
@@ -15,7 +15,8 @@ services.AddMvc();
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
- options.IdleTimeout = TimeSpan.FromSeconds(10); // testing timeout
+ // for testing timeout TimeSpan.FromSeconds(10);
+ options.IdleTimeout = TimeSpan.FromMinutes(20);
options.Cookie.Name = ".AspNetCore.Session";
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;