User talk:Patrick Nagel/Login with snoopy post-1.15.3

Be independent of the cookie name
Instead of:
 * $snoopy->cookies["wiki_session"] = $response[login][sessionid];

I used:
 * $snoopy->cookies = getCookieHeaders($snoopy->headers);

and the function getCookieHeaders is: function getCookieHeaders($headers){ $cookies = array; foreach($headers as $header) if(preg_match("/Set-Cookie: ([^=]*)=([^;]*)/", $header, $matches)) $cookies[$matches[1]] = $matches[2]; return $cookies; }
 * 1) This function parses Snoopy's header array and returns a nice array of cookies

It works better because you don't have to know the name of the cookie in advanced. (I took the function from http://www.mail-archive.com/mediawiki-api@lists.wikimedia.org/msg00099.html)
 * Thanks, I added a link to your proposal. --Patrick Nagel 02:38, 23 July 2010 (UTC)