tolsen64
tolsen64

Reputation: 999

C# HttpWebRequest - Why aren't all received cookies being sent back on subsequent requests?

The following cookies are being sent by the server after successful validation:

Server: 
X-XSS-Protection: 1
X-AspNetWebPages-Version: 3.0
Set-Cookie: EmpID=xOjoyivp84OC6KkV0w4hXLfclbzX2mpB+HTbZPGztus=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: AccessLev=qTxevtKQJG2aZZxwqpGn4w==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: GemsID=r2d2IJopaNhaaq2Xw74xpVDU12/KDqTpsQM0problpk=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: CurEmp=olSY3jYBGUap+wage0B2vA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: DeptID=5GWJbAVQFjgl8iryDpRXwDMZ1TyR1Yy5MIAPqrjQvQ8=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: RegionID=CS/ZvhjT4U6SZTleOntODw==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: DistrictID=0S72z9jx4ausKB/FMt/JBA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: SupGrpID=pWWsYnDC+RKT/afWrJ1xYtZ2no5TWNQQRSdGznFVnsI=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: Uploader=mdDmHcf27f4q9X7cQ6UE9g==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: PTSupEmp=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: MultiStat=olSY3jYBGUap+wage0B2vA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: EmpInits=F2Hrvzdk1Dn6RQxn1DWK+A==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: PayrollStat=UtEDM/pSJ+Y/Htbr1pQdbw==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: RepType=olSY3jYBGUap+wage0B2vA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: RepDef=olSY3jYBGUap+wage0B2vA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: WeDate=azx53p/DcTjBIxxpLa4zBNGMR+e201n0mjRcVB94ZdM=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: Debug=olSY3jYBGUap+wage0B2vA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: DispVal=olSY3jYBGUap+wage0B2vA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: SortOpt=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: CardClass=olSY3jYBGUap+wage0B2vA==; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
Set-Cookie: WkDate=tFlsOD63+0Xu8kKB9lQcjadYk77Y4ifd6aNJBKoJggI=; expires=Sat, 28-Sep-2019 01:46:43 GMT; path=/; secure; HttpOnly
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
Date: Fri, 27 Sep 2019 01:46:43 GMT
Content-Length: 142

However, 1 of the cookies are not being sent back after being redirected to the main page. Namely EmpID. I've been unable so far to determine why. None of the suggested solutions I've found on S.O. has worked for me.

Cookie: 
AccessLev=qTxevtKQJG2aZZxwqpGn4w==; 
GemsID=r2d2IJopaNhaaq2Xw74xpVDU12/KDqTpsQM0problpk=; 
CurEmp=olSY3jYBGUap+wage0B2vA==; 
DeptID=5GWJbAVQFjgl8iryDpRXwDMZ1TyR1Yy5MIAPqrjQvQ8=; 
RegionID=CS/ZvhjT4U6SZTleOntODw==; 
DistrictID=0S72z9jx4ausKB/FMt/JBA==; 
SupGrpID=pWWsYnDC+RKT/afWrJ1xYtZ2no5TWNQQRSdGznFVnsI=; 
Uploader=mdDmHcf27f4q9X7cQ6UE9g==; 
PTSupEmp=; 
MultiStat=olSY3jYBGUap+wage0B2vA==; 
EmpInits=F2Hrvzdk1Dn6RQxn1DWK+A==; 
PayrollStat=UtEDM/pSJ+Y/Htbr1pQdbw==; 
RepType=olSY3jYBGUap+wage0B2vA==; 
RepDef=olSY3jYBGUap+wage0B2vA==; 
WeDate=azx53p/DcTjBIxxpLa4zBNGMR+e201n0mjRcVB94ZdM=; 
Debug=olSY3jYBGUap+wage0B2vA==; 
DispVal=olSY3jYBGUap+wage0B2vA==; 
SortOpt=; 
CardClass=olSY3jYBGUap+wage0B2vA==; 
WkDate=tFlsOD63+0Xu8kKB9lQcjadYk77Y4ifd6aNJBKoJggI=

Upvotes: 1

Views: 69

Answers (1)

tolsen64
tolsen64

Reputation: 999

After banging my head for an embarrassing amount of time over this, I finally figured it out. The cookie container has a default cookie limit of 20. There were 21 cookies being sent and when the 21st cookie came in, the first cookie was dumped. So now I instantiate my cookie container like so:

Before:

Public myCookieContainer = New CookieContainer()

After

Public myCookieContainer = New CookieContainer(500, 500, 4096)

Upvotes: 1

Related Questions