stukerr
stukerr

Reputation: 716

Apache / PHP Disable Cookies for Subdomain?

I am trying to follow these guidelines to make my page load quicker.

I have created a static subdomain to load static content from, however it is advising me to not have cookies sent on this subdomain, any ideas on how I might be able to do this in Apache/PHP?

I've searched around and come up with nothing yet.

Upvotes: 10

Views: 11520

Answers (2)

Tyler Carter
Tyler Carter

Reputation: 61567

If you never explicitly set a cookie, cookies won't be present on the server. So, if you are using the second domain simply as a repository for images or CSS files, most likely no cookies are ever set.

Updated from Comments.

If you see a 'Request' cookie header to a subdomain you don't want to have cookies, clear your cookies and see if the server ever sends a cookie header in the Response headers. If it does, it is possible you have session.auto_start enabled, or you have a script that sets cookies.

You can check the Request and Response Headers using something like Firebug with Google Page Speed.

Upvotes: 6

Brad Gignac
Brad Gignac

Reputation: 819

You can easily take care of this in PHP. When you set your cookie, the parameter that needs to be set is the domain parameter. Often, this is set to ".domain.com" to make it available on any subdomain. Instead, you might try setting it to "www.domain.com" to restrict it to that domain. Check out the PHP manual's setcookie() documentation.

Upvotes: 0

Related Questions