I have a string defined like:
DEFINE('IMAGES_DIR',"/portal/images/");
After I place it inside of a cookie its content becomes
%2Fportal%2Fimages%2F
I need the string to return like:
/portal/images/
I'm kinda combining two answers mentioned here.
what you described is the default behaviour, PHP will automatically decode it to its original value, you don't need to do urldecode($_COOKIE['name']);
You can prevent automatic url encoding by using setrawcookie()
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.
Use urldecode when getting cookie value:
echo urldecode('%2Fportal%2Fimages%2F');
or
//for cookie
echo urldecode($_COOKIE['IMAGES_DIR']);
//for your example above with the contant
echo urldecode(IMAGES_DIR);
$_COOKIE.
setrawcookieor urldecode it later