setCookieArray( $arr, $cookie, $minutes ) {
$json = serialize( $arr );
if( strlen( $json ) > 4096 ){
foreach( $arr as $key => $val ){
if( is_array( $val ))
setCookieArray( $val, $cookie .'_a_'. $key, $minutes )
else
cookie( $cookie .'_v_'. $key, $val, $minutes);
}
} else {
cookie('name', $json, $minutes);
}
}
setCookieArray( array(
'category'=>array(
'0'=>1,
'1'=>15,
'2'=>7,
'3'=>76,
)
), 'mycookie', 10);