简体   繁体   中英

PHP cookie is not url safe

I am using PHP to create cookie using

setcookie("key", "value@value");

but if we check the cookie in browser resources it shows value%40value . I need it to be value@value

When I created cookie using Java, I see proper value value@value .

I already tried urldecode and urlencode functions. None of them worked.

You need to be using setrawcookie() . Take a look at what the docs have to say on the subject:

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() instead if you are using PHP 5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM