parsing a subcookie query string like this: cookiename=name1=value1&name2=value2&name

Suppose you use a subcookie, which is a way to save multiple variables in the same cookie:


Is there a built in php function that could parse such a query string?

I was not familiar with the use of subcookies until I went here:
YUI 2: Cookie Utility (scroll down to the bottom)

figured it out

use urlencode, or http_build_query to create a sub cookie string,
then use parse_str() to get the variables.

echo $string = http_build_query(array(‘name’ => ‘test’, ‘last’ => ‘user’));
echo $name;
echo $last;

This is not an optimal solution because with parse_str() from user submitted data would allow just anyone to create whatever variables they wanted.