Frequently Asked Questions

Help Center Search

Why is ASP being blocked on my server when attempting to read cookies?

Print this Article
Comment on this Article
Last Updated: March 22, 2007 11:07 AM

Symptom:

ASP is blocked when attempting to read cookies on an aliased domain. For example:

Main Domain: http://www.coolexample.com

Alias Domain: http://www.coolexample.org

Alias Folder: /coolexample_org

This works: http://coolexample.com/coolexample_org/cookies.asp

This does not work: http://coolexample.org/cookies.asp

Cause:

When an aliased domain is inside a sub-application within the application root, the cookie is created with a default path of the sub-folder. For example:

Name: CE

Content: Cookie+Value

Host: coolexample.com

Path: /coolexample_org

When a cookie call is made, by default it does not include a path. As a result, cookies work on the primary domain, but not the aliased one.

Resolution:

When you create a cookie, you need to add a line of code to reflect the correct path for that subdomain.

Response.Cookies("CE").Path=""

Where CE is the name of your cookie. This will create the following cookie:

Name: CE

Content: Cookie+Value

Host: coolexample.com

Path: /

For more information, see Maintaining Session State with Cookies on the MSDN Web site.