Reputation: 7060
I set my cookie with PHP like this:
setcookie(
"hero",
", Comma . Dot < Left > Right - Dash _Underline / Slash \\ Backslash",
time() + (10 * 365 * 24 * 60 * 60));
But somehow, this is the value of the cookie:
%2C+Comma+.+Dot+%3C+Left+%3E+Right+-+_Underline+%2F+Slash+Backslash
And not:
, Comma . Dot < Left > Right - Dash _Underline / Slash \ Backslash
echo $_COOKIE["hero"];
And that resulted in:
, Comma . Dot < Left > Right - Dash _Underline / Slash \ Backslash
Why is this so?
Upvotes: 2
Views: 818
Reputation: 38502
You can set raw cookie then value will remain unchanged, Then value will not be automatically urlencoded when sent to the browser. for more info
http://www.php.net//manual/en/function.setrawcookie.php
Upvotes: 1
Reputation: 671
PHP automatically url encodes the value portion of a cookie when it is set.
Read the PHP Manual entry on setcookie();
Upvotes: 2