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;
<?php
$content = file_get_contents('http://drupalsite.com');
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.
Answer
Solution:
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?)