views:

412

answers:

1

I am using the following code to set a session cookie

        HttpCookie cookie = new HttpCookie("visitId");
        cookie.Value = value;
        cookie.Domain = ".example.com";

        Response.Cookies.Set(cookie);

This works fine, although I was surprised to see in IE8 when I hit F12 (developer tools) and then 'Cache > View Cookie Information' I get the following. It says '.com' instead of 'example.com'

NAME  visitId 
VALUE  1472215 
DOMAIN  .com 
PATH  / 
EXPIRES  At the end of the Session

The HTTP header sent says this :

Set-Cookie: visitId=1472215; domain=.example.com; path=/

Whats going on? Why is IE8 showing only .com for the domain? Is this just the way session cookies work. That doesnt make sense of course.

What was interesting to me is that a persistent cookie shows this, when set using the same code.

NAME  userGUID 
VALUE  e1cbe4f3-6300-44e1-a702-b449d5711816 
DOMAIN  example.com 
PATH  / 
EXPIRES  3/27/2010 1:05:14 AM

Am I misunderstanding something or is this just a bug in their 'cookie' display logic?

I've verified at least that it isn't sending the cookies to stackoverflow.com :-)

A: 

If the cookie send with the HTTP header is correct, then it looks like a developer tools bug?!

Mork0075
thats what i was wondering. I've tried with or without the period at the beginning of the domain name. I was never clear what the difference was though.
Simon_Weaver
what i find strange though is the developer tool is just showing me an xslt transformation for an XML file : C:\Users\SWEAVER\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5\Coo7E87.xml (yes it does say IE5 !!!)
Simon_Weaver
A cookie with a domain starting with a period is valid for that domain and any subdomains, whereas without a period it's just valid for that domain. I would imagine this is just a developer tools bug too though.
Gareth