0

I've set up a sub-domain on my server that serves css and images (to avoid cookies). The 1st time the page loads, everything is fine. The 2nd time however, I see that the css and images contain cookies. Is there something I'm missing?

EDIT: Solution found, the following text clarifies the issue.

Restricting google analytics to my main domain prevented subsequent cookie requests to my static subdomain (images, css, etc.). 2nd topic on this web page.

  • Can you explain your server setup? Are you using Apache, do you have PHP installed if so, etc. What is being returned in the cookies exactly? Without knowing what is being returned, it's hard to find the exact problem. Edit: You might want to check http://stackoverflow.com/questions/1165831/apache-php-disable-cookies-for-subdomain also. – William Jan 22 '10 at 20:26

3 Answers3

0

It's hard to answer your question without knowing what http server you're using, etc. The best way to figure out how the cookies are being created is to figure out what cookies are being returned.

For instance, PHP (by default) stores the session ID in the cookie PHPSESSID. If you're making a new HTTP request (without sending a PHPSESSID in your initial request) and it's returning a PHPSESSID, then that would mean PHP is obviously the culprit. Since I doubt you're retrieving the images and CSS files through a PHP script that initializes a new session, it would show that PHP is configured to initialize sessions automatically via the session.auto_start PHP configuration variable.

William
  • 15,465
  • 8
  • 36
  • 32
  • Host: canaca.ca Server: Apache 2.2.11 PHP: 5.2.6 I think it may be a session cookie as it has info like "__utma=". I tried putting in "php_flag session.auto_start 0" into the .htaccess that resides in the subdomain, and the CSS wouldn't even load. EDIT: Nothing under response headers though. Should I not worry then? – SnakeWasTheNameTheyGaveMe Jan 22 '10 at 22:26
  • Also, I found http://www.askapache.com/javascript/google-analytics-speed-tips.html which might be of some use. – SnakeWasTheNameTheyGaveMe Jan 22 '10 at 22:37
  • Yeah the cookies you're talking about is from Google Analytics. You'll need to change the JavaScript code that Google Analytics gave you to tell it to only set cookies on a specific domain or ignore the sub domain. If you look at the 2nd section the page you sent me, it tells you how to do this. – William Jan 22 '10 at 23:20
0

I found that setting up a separate static domain took away all the hassle of ensuring cookies didn't creep into the main domain. Exactly like how stackoverflow uses http://sstatic.net/, I created http://cnstatic.com/ for my own site/blog.

Corey Hart
  • 10,316
  • 9
  • 41
  • 47
0

Set correct domain for Analytics.