we have an issue with the Session Middleware in asp.net core . actually if i am trying to access application from one host it's working fine. then with same host if i am trying to access the another application. the [previously opened ] / first application's
session getting cleared .
what will be issue with session/ session middleware . please advise.
None
0 Points
4 Posts
Issue with session in asp.net core session middle ware.
May 19, 2020 01:31 PM|muna.sethi@arcadix.com|LINK
Hi,
we have an issue with the Session Middleware in asp.net core . actually if i am trying to access application from one host it's working fine. then with same host if i am trying to access the another application. the [previously opened ] / first application's session getting cleared .
what will be issue with session/ session middleware . please advise.
using below in application processing pipeline
UseSession();
UseCookiePolicy
and the service is configured using -
CookiePolicyOptions
AddSession
All-Star
58474 Points
15790 Posts
Re: Issue with session in asp.net core session middle ware.
May 19, 2020 03:16 PM|bruce (sqlwork.com)|LINK
what are the urls of the two applications?
None
0 Points
4 Posts
Re: Issue with session in asp.net core session middle ware.
May 20, 2020 10:09 AM|muna.sethi@arcadix.com|LINK
The URLs let say
1st -- https://example.com/Application1?sessionkey=12344
2nd -- https://example.com/Application2?sessionkey=12564
after accessing the first one and then after if i access 2nd application the session of 1st application is getting cleared automatically.
All-Star
58474 Points
15790 Posts
Re: Issue with session in asp.net core session middle ware.
May 20, 2020 02:32 PM|bruce (sqlwork.com)|LINK
And what is your session configuration?
None
0 Points
4 Posts
Re: Issue with session in asp.net core session middle ware.
May 21, 2020 04:47 AM|muna.sethi@arcadix.com|LINK
service --
service.Configure<CookiePolicyOptions>(options =>
{
options.CheckConsentNeeded = context => false;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
service.AddDistributedRedisCache(options =>
{
options.Configuration = AppSettings.Properties["abcd"].ToString();
options.InstanceName = "aserd";
});
objServiceCollection.AddSession(options =>
{
options.Cookie.Name = "xyz";
options.IdleTimeout = TimeSpan.FromMinutes(90);
options.Cookie.HttpOnly = false;
options.Cookie.IsEssential = true;
});
application processing pipeline :-
application.UseSession();
application.UseCookiePolicy();
All-Star
58474 Points
15790 Posts
Re: Issue with session in asp.net core session middle ware.
May 21, 2020 04:40 PM|bruce (sqlwork.com)|LINK
use the browser debugger to check the domain of the session cookie. they probably match. so app2 replaces app1 session cookie with its session id.
None
0 Points
4 Posts
Re: Issue with session in asp.net core session middle ware.
May 25, 2020 07:48 AM|muna.sethi@arcadix.com|LINK
Hi,
yes, the domains are same for both the cookies. so, you mean the domain for both the cookies can't be same.
All-Star
58474 Points
15790 Posts
Re: Issue with session in asp.net core session middle ware.
May 25, 2020 04:12 PM|bruce (sqlwork.com)|LINK
That’s correct. As each site has its own session Id they cannot use the same cookie. Change the domain or cookie names.