views:

1489

answers:

4

Okay, this is really kinda starting to bug me. I have a simple Web project setup located at: "C:\Projects\MyTestProject\". In IIS on my machine, I have mapped a virtual directory to this location so I can run my sites locally (I understand I can run it from Visual Studio, I like this method better). I have named this virtual directory "mtp" and I access it via http://localhost/mtp/index.aspx. All this is working fine.

However, whenever I try to create a cookie, it simply never gets written out? I've tried this in FF3 and IE7 and it just plain won't write the cookie out. I don't get it. I do have "127.0.0.1 localhost" in my hosts file, I can't really think of anything else I can do. Thanks for any advice.

James

A: 

Are you assigning an expiration date to the cookie? By default, the cookie will expire when the browser session expires, meaning it won't write anything to disk.

Robert C. Barth
A: 

Something like fiddler or burp can be used to monitor the network communication between the browser and the web server. It may be able to help determine how the cookie is being set.

A code sample of what you are doing in ASP.Net would probably be most helpful to answer your question however.

Peter Oehlert
A: 

Thanks for the response, guys. I did actually get this figured out, but I'm not 100% sure on how I went about it. I think I just had the virtual directory configuration messed up in IIS, but it's all working now.

James McConnell
+4  A: 

The cookie specs require two names and a dot between, so your cookiedomain cannot be "localhost". Here's how I solved it:

  1. Add this to your %WINDIR%\System32\drivers\etc\hosts file: 127.0.0.1 dev.livesite.com

  2. When developing you use http://dev.livesite.com instead of http://localhost

  3. Use ".livesite.com" as cookiedomain (with a dot in the beginning) when creating the cookie.

  4. Now it works on all sites:

Sire
Worked for me. Thanks.
Robin Robinson