Re: base64-encoding in cookies?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fletcher Mattox wrote:
Actually, wouldn't you say it is left up to whoever is sending the cookie?
But more on that later.
It is totally left up to the user with PHP as well, but you agree with that (grudgingly) later. There is no way that you can argue the fact that there are two mechanisms. One leaves total control up to the user, the other is totally automatic. Personally, I think that's having your cake, and eating it too.

I won't argue that this behavior should probably be documented with $_COOKIE, but it is documented with it's counterpart, setcookie: "Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. If you don't want this, you can use setrawcookie() <http://www.php.net/manual/en/function.setrawcookie.php> instead if you are using PHP 5."

In terms of the behavior, I think it makes total sense. The only case where it would ever bite you is yours (which is rare because most people wouldn't mix perl and PHP in the same system). Nearly every other case is neatly wrapped up - newbies will find that setting whatever cookies they want just works, regardless of content. Others who are aware of the encoding behavior probably don't care - it's what they'd do manually if PHP didn't do it for them. Even if you use cookies in JavaScript, you'll have to know that certain charaters would have to be escaped, so you'd run escape on your cookie and find that in PHP you don't even have to do anything and it just works. (And more or less vice-versa.)

As far as I'm concerned, that is the mentality of PHP: there's a function called: do_exactly_what_i_want(), and it just works.

I think some of the negativity aimed at you stems from the fact that the behavior has been explained and is quite clear. There isn't much point in arguing what it should be. It is exactly what it is. If you want to argue what the behavior should be, try php-dev. (Making that kind of argument here is like yelling at your neighbor 'cause Vista sucks...assuming Bill Gates isn't your neighbor. :-)

jon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux