note 59925 deleted from reserved.variables by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:23:50 +0000 |
| Subject: | note 59925 deleted from reserved.variables by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134353@lists.php.net to get a copy of this message | ||
Note Submitter: Andy Staudacher, gmx.ch add ast before @
----
The following code is licensed under the GPL and it is from the gallery.menalto.com project.
<?php
/**
* Fix the superglobal $_COOKIE to conform with RFC 2965
*
* We don't use $_COOKIE[$cookiename], because it doesn't conform to RFC 2965 (the
* cookie standard), i.e. in $_COOKIE, we don't get the cookie with the most specific path
for
* a given cookie name, we get the cookie with the least specific cookie path.
* This function does it exactly the other way around, to a) fix our cookie/login problems and
* to b) conform with the RFC.
* The PHP bug was already fixed in spring 2005, but we will have to deal with broken PHP
* versions for a long time. See http://bugs.php.net/bug.php?id=32802.
*
* Fixes also another PHP cookie bug. PHP doesn't expect the cookie header to have
* quoted-strings, but they are perfectly legal according to RFC 2965.
*
* The third bug fixed here is an MS Internet Explorer (IE) bug. When using default cookie
* domains (no leading dot, don't set the domain in set-cookie), IE is supposed to return
only
* cookies that have the exact request-host as their domain.
* Example: Cookies stored in the browser with cookie domains: .example.com, .www.example.com,
* example.com, www.example.com
* The request-host is www.example.com. Thus, IE should return all those cookies but
* the example.com cookie, because it's a default domain cookie and it
doesn't match
* exactly the request-host. But IE returns the example.com cookie too.
* As MS decided that it returns the cookie with the best domain-match first (unspecified in
* RFC 2965), this wouldn't be a problem if PHP didn't select the last cookie in the
* HTTP_COOKIE header. But with fixCookieVars(), this case is also fixed.
*
* This function reevaluates the HTTP Cookie header and populates $_COOKIE with the correct
* cookies. We fix only non-array and non '[', ']' containing cookies for
simplicity. To fix
* our login problem, we'd have to fix only the GALLERYSID cookie anyway.
*
* @param boolean force the reevaluation of the HTTP header string Cookie
* @param boolean unset static variable for testability
*/
function fixCookieVars($force=false, $unset=false)
?>
The source code can be found at:
http://cvs.sourceforge.net/viewcvs.py/gallery/gallery2/
modules/core/classes/GalleryUtilities.class?rev=1.146&view=markup