If you can use ISessionState.Keys collection to count the active session, but default session manager does not track session to user.
How to get all active session of the logged in user in .net core mvc
John Russel Punio
0
Reputation points
I'm currently working on a .net 7 mvc project. How can I get all the active sessions of a logged in user in .net core mvc. This is my setup currently:
builder.Services.AddDistributedSqlServerCache(options =>
{
options.ConnectionString = config.Database.ConnectionString;
options.SchemaName = "dbo";
options.TableName = "TestCache";
options.DefaultSlidingExpiration = TimeSpan.FromMinutes(240);
});
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(120);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
options.Cookie.Name = $".{Host}.Session";
});