php - Set a $_cookie value in an array -


i have cookie following value:

2,3 personen klein,47.50,images/portfolio/portfolio-02.jpg,1|1,2 personen kleurrijk,47.50,images/portfolio/portfolio-01.jpg,1|3,sneeuwklokje,47.50,images/portfolio/portfolio-03.jpg,1 

i value when use:
echo $_cookie['cart'];

the | delimiter new line , , delimiter new value.

how can put these values in array becomes useable echo parts of it, example when want echo images. hope guys can give me tips.

$array = explode("|", $_cookie['cart']);  foraech($array & $element) {    $element = explode(",", $element); }  // example - echo image echo $array[1][3] 

but honest should keep in $_session. can store arrays, objects, long strings etc. there , user not able change contents

  • cookies not storing complex data

  • everyone can change cookies manually , can lead security issues

  • there limit 4096 bytes per 1 cookie


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -