In your case you have two urls: one is a https://domain.com
and second one is a https://domain.com/applogin
. Let's assume that CookieContainer contains your cookie for path /applogin. This means that if you will try to retrieve list of cookies for url https://domain.com/applogin
- you will get one cookie. If you will try to retrieve cookies for url https://domain.com
- you will get 0 cookies.
Now let's look on your sample. You have a cookie for https://domain.com/applogin
and you are trying to add it to CookieContrainer for url https://domain.com
. CookieContainer verifies that this cookie cannot be used for specific url, because it was issues for different url. In your case you need to change line where you add cookie:
webRequest.CookieContainer.Add(new Uri(@"https://domain.com/applogin"), newCookie);
Or I guess you want to use this cookie for whole domain.com - then you need to change how you create it to
Cookie newCookie = new Cookie("JSESSIONID", session.SessionId, "/", "domain.com");