<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Click here to delete cookies</title>
	<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies/</link>
	<description>Comments on Ask MetaFilter post Click here to delete cookies</description>
	<pubDate>Fri, 12 May 2006 12:43:38 -0800</pubDate>
	<lastBuildDate>Fri, 12 May 2006 12:43:38 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Click here to delete cookies</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies</link>	
		<description>What code can I include on my site to delete all cookies it has set? &lt;br /&gt;&lt;br /&gt; I&apos;m using Drupal on my site, and every once in a while, I can&apos;t log in. Asking on the Drupal forums has shown me that the fix (until someone finds the underlying bug that&apos;s causing the problem) is to delete the cookie for your site.&lt;br&gt;
&lt;br&gt;
I want to provide something for the less technical of my site&apos;s members, where I can have a link that says &quot;If you are experiencing this problem, click here&quot; and it will delete all the cookies set by my site.  Is this possible?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.38081</guid>
		<pubDate>Fri, 12 May 2006 12:26:43 -0800</pubDate>
		<dc:creator>RobotHero</dc:creator>
		
			<category>cookies</category>
		
			<category>html</category>
		
	</item> <item>
		<title>By: RustyBrooks</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589279</link>	
		<description>I don&apos;t know anything about drupal, and I don&apos;t know what kind of web server you&apos;re using, but it&apos;s still possible with some programming.&lt;br&gt;
&lt;br&gt;
Every time a user visits any page on your site, they send ALL the cookies that their browser has, which were given to them by your site.  This is in the &quot;cookies&quot; header.  Whatever server you have, and whatever programming language you have access to, you can grab this header and parse the cookie names out of it.  Then, you can re-send the cookies with an immediate expiration time.&lt;br&gt;
&lt;br&gt;
The actual details of this are left as an excercise since it&apos;ll depend a lot on your platform and programming language.  Once you figure out how to grab the actual value of the cookies header, you&apos;ll see what I mean, the cookes are &quot;packed&quot; into the cookie header in an easily parseable format.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589279</guid>
		<pubDate>Fri, 12 May 2006 12:43:38 -0800</pubDate>
		<dc:creator>RustyBrooks</dc:creator>
	</item><item>
		<title>By: AmbroseChapel</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589291</link>	
		<description>Rusty&apos;s right. To put it in as few words as possible, &lt;em&gt;you can&apos;t delete them, but you can expire them. &lt;/em&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589291</guid>
		<pubDate>Fri, 12 May 2006 12:56:30 -0800</pubDate>
		<dc:creator>AmbroseChapel</dc:creator>
	</item><item>
		<title>By: misterbrandt</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589292</link>	
		<description>Drupal is PHP-based, I believe. There is a user-contributed &quot;delete all cookies&quot; script &lt;a href=&quot;http://us3.php.net/manual/en/function.setcookie.php#52081&quot;&gt;at the PHP site&lt;/a&gt;:&lt;br&gt;
&lt;pre&gt;&lt;br&gt;
$cookiesSet = array_keys($_COOKIE);&lt;br&gt;
for ($x = 0; $x &lt; count($cookiesset); $x++) {br&gt;
   if (is_array($_COOKIE[$cookiesSet[$x]])) {&lt;br&gt;
       $cookiesSetA = array_keys($_COOKIE[$cookiesSet[$x]]);&lt;br&gt;
       for ($c = 0; $c &lt; count($cookiesseta); $c++) {br&gt;
           $aCookie = $cookiesSet[$x].&apos;[&apos;.$cookiesSetA[$c].&apos;]&apos;;&lt;br&gt;
           setcookie($aCookie,&quot;&quot;,time()-1);&lt;br&gt;
       }&lt;br&gt;
   }&lt;br&gt;
   setcookie($cookiesSet[$x],&quot;&quot;,time()-1);&lt;br&gt;
}&lt;/&gt;&lt;/&gt;&lt;/pre&gt;&lt;br&gt;
&lt;br&gt;
So you could wrap that in a function and call it as needed. (&lt;small&gt;please advise if I am glossing over details you need or speaking beneath your skill level here -- you don&apos;t indicate your own skillset in the Q. I assume since you are administering a drupal site that you can dabble in PHP&lt;/small&gt;) You can also delete all cookies from javascript, but it is preferable to have a server-side method to fall back on.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589292</guid>
		<pubDate>Fri, 12 May 2006 12:57:06 -0800</pubDate>
		<dc:creator>misterbrandt</dc:creator>
	</item><item>
		<title>By: misterbrandt</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589296</link>	
		<description>&lt;a href=&quot;http://sharkysoft.com/tutorials/jsa/content/046.html&quot;&gt;This page&lt;/a&gt; has a &lt;code&gt;delete_all_cookies&lt;code&gt; function implemented in Javascript -- down a ways.&lt;/code&gt;&lt;/code&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589296</guid>
		<pubDate>Fri, 12 May 2006 12:59:50 -0800</pubDate>
		<dc:creator>misterbrandt</dc:creator>
	</item><item>
		<title>By: moift</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589346</link>	
		<description>time() - 1 isn&apos;t reliable from the server side, since the cookie will use at the client&apos;s clock setting.  Just use a static date several years ago.  (Doesn&apos;t apply to the javascript solution since it has access to the user&apos;s clock.)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589346</guid>
		<pubDate>Fri, 12 May 2006 13:46:03 -0800</pubDate>
		<dc:creator>moift</dc:creator>
	</item><item>
		<title>By: o2b</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589350</link>	
		<description>&lt;a href=&quot;http://www.squarefree.com/bookmarklets/zap.html&quot;&gt;This page&lt;/a&gt; has a number of useful bookmarklets, including &quot;zap cookies&quot;, which I use all the time.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589350</guid>
		<pubDate>Fri, 12 May 2006 13:50:23 -0800</pubDate>
		<dc:creator>o2b</dc:creator>
	</item><item>
		<title>By: RobotHero</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589366</link>	
		<description>&lt;b&gt;I assume since you are administering a drupal site that you can dabble in PHP&lt;/b&gt; - misterbrandt &lt;br&gt;
&lt;br&gt;
Yes.&lt;br&gt;
&lt;br&gt;
I assume I have to use the php code in the header? (Like, I can&apos;t just cram it into the middle of my template and expect it to work.)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589366</guid>
		<pubDate>Fri, 12 May 2006 14:05:12 -0800</pubDate>
		<dc:creator>RobotHero</dc:creator>
	</item><item>
		<title>By: misterbrandt</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589379</link>	
		<description>I am not familiar with drupal, so I can&apos;t advise whether it is pretty easy to turn that function into a plugin or what. Simplest thing I would do is actually just save it as &apos;&lt;code&gt;deletecookies.php&lt;/code&gt;&apos; in the root of your folder, and then from drupal make a link that says &quot;having trouble logging in? _click here_&quot; pointing that file. You could then add a &lt;code&gt;header(&quot;Location: /&quot;);&lt;/code&gt; to redirect users to your site root once the cookies are cleared, but theat doesn&apos;t give any visual feedback that anything happened. Maybe just have that page display a &quot;&lt;em&gt;all cookies have been cleared! return to the _login page_&lt;/em&gt;&quot; message when it is done. (heck, throw a meta-redirect to redirect there automatically after x seconds too)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589379</guid>
		<pubDate>Fri, 12 May 2006 14:18:54 -0800</pubDate>
		<dc:creator>misterbrandt</dc:creator>
	</item><item>
		<title>By: fishfucker</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589465</link>	
		<description>&lt;i&gt;I assume I have to use the php code in the header? (Like, I can&apos;t just cram it into the middle of my template and expect it to work.)&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
I can&apos;t quite recall (and I&apos;m too lazy to look up), that any cookie manipulation in PHP must be done PRE-output -- ie, before you send the headers. And I also believe that you should do a header(&quot;location:&quot;.$_SERVER[&quot;PHP_SELF&quot;]) once you&apos;re done twiddling those bits.&lt;br&gt;
&lt;br&gt;
however, ymmv, since most of my memory has been pissed away many years ago.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589465</guid>
		<pubDate>Fri, 12 May 2006 16:15:22 -0800</pubDate>
		<dc:creator>fishfucker</dc:creator>
	</item><item>
		<title>By: misterbrandt</title>
		<link>http://ask.metafilter.com/38081/Click-here-to-delete-cookies#589469</link>	
		<description>&lt;em&gt;I assume I have to use the php code in the header? (Like, I can&apos;t just cram it into the middle of my template and expect it to work.)&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
Yes. You can&apos;t do any &lt;code&gt;header()&lt;/code&gt; work or set any cookies after output has already been sent.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.38081-589469</guid>
		<pubDate>Fri, 12 May 2006 16:17:55 -0800</pubDate>
		<dc:creator>misterbrandt</dc:creator>
	</item>
	</channel>
</rss>
