php - Stop cookies being set


This is a bit of a strange one. I have a request that a page on a clients site not set any cookies. The problem is that the site runs on Drupal, which relies quite heavily on cookies. I had an idea to create a standalone PHP script, and pull the contents of the Drupal page into a variable and then echo the variable in the hope it wouldn't create the cookie.

However, the same Cookies are still set.

My code is as simple as it can get in the standalone script;


$content = file_get_contents('');
echo $content;

I've also tried experimenting and addingini_set('session.use_cookies', '0'); to the standalone script and even creating a subdirectory and adding the following to a .htaccess file

Header unset Cookie
Header unset Set-Cookie

No matter what I do, cookies are still being set.




What you've attempted is a sensible way to address the problem. The only reasons for cookies still being dropped are:

1) The cookie is being set by javascript, not by the webserver - have you checked the HTTP headers?

2) The cookie is being set by the webserver config or by an auto-prepend script - you didn't say what the webserver was - have you checked it's config?

3) your analysis is wrong - (again, have you checked the headers?)

People are also looking for solutions to the problem: php - Change category of wordpress post when date is today


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.