473,372 Members | 854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Strange behaviour with GetCookies()


I have been working on some code that interacts with a website using
the HTTPRequest object and I have come across an issue where cookies
behave differently in the dotnet framework to the way they behave in
Internet Explorer and FireFox.
If I visit the website in question, it returns a cookie with a
full stop (or period for our US cousins) in the domain part of the
cookie - for example: ".www.mydomain.com".
The problem with this is that IE will return that cookie for any
subsequent requests to www.mydomain.com whereas a call to the dotnet
framework's CookieContainer.GetCookies("http://www.mydomain.com")
not return that cookie. Does anyone have any experience of the issue
or have any suggestions for a workaround (I do not have access to the
source code for the website and therefore I can't simply remove the
leading ".")
I have included a C# snippet of code which demonstrates the problem
Uri thisUri = new Uri("http://www.mydomain.com/somepage.aspx");
Cookie thisCookie = new Cookie("SessionID",
"ABCDEFG1234567890", "/", ".www.mydomain.com");

CookieContainer myCookieContainer = new CookieContainer();
CookieCollection myCookieCollection = new CookieCollection();


myCookieCollection = myCookieContainer.GetCookies(new Uri("http://
string sCookie = "";
foreach (Cookie tempCookie in myCookieCollection)
sCookie += tempCookie.Name;

Jun 27 '08 #1
0 1140

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ...
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
by: guyhey | last post by:
I am accessing a site that passes the following headers: Set-Cookie: ASP.NET_SessionId=pwdciy45i0c5me45urxjfoi0; path=/ Set-Cookie: LastSessID=pwdciy45i0c5me45urxjfoi0; expires=Tue, 01-Mar-2016...
by: Gotch | last post by:
Hi, I'm getting a very strange behaviour while running a project I've done.... Let's expose it: I've two projects. Both of them use a Form to do some Gui stuff. Other threads pack up messages...
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code -----------------------------------...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.