Question

IS there any way to prevent ASP.NET to write a cookie in the browser client. When I looks at the developer tools in chrome I see this:

Cookie:ASP.NET_SessionId=cl5kl1khetb3quyoicikdkvm

which means cookie was set for my Default.aspx page. The reason I don't want to have cookie written to the client is that I am using the domain 'domain.com without www. IF cookie is written, it will be appended to every static item server from CDN.domain.com, including images, JS code, etc.

I am thinking of using www to prevent cookies to be attached to cdn.mydomain, but I wanted to know what is the better solution and whether setting my site not to serve cookies will make it work.

Was it helpful?

Solution

The correct way to disable this particular cookie is to turn off session state support for your application.

You can also force all requests to always go to WWW domain by setting redirect from .mysite.com domain that will not set cookies.

Safe apporach would be to have CDN on separate domain altogether. This way you can share cookies between all sub-sites of *.mysite.com and still have cookieless CDN at something like cdnmysite.com. You may not need separate site for it just different CNAME record pointing to the same site (I don't know if Amazon's CDN supports it or provides any help with setting it up).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top