How to write a array in the cookie

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raji20
    New Member
    • Aug 2006
    • 28

    How to write a array in the cookie

    Hello Guys,

    Hope u all are doing great. Canyou suggest me how to write a array in the cookie, for eg,

    [php]
    $var = array("1","2"," 3");

    [/php]

    Now I want to set a cookie which should store this array $var. I dont want to use for loop for storing the array value in the cookie

    Can anyone help me............

    Thanks a lot in advance
  • billkirim
    New Member
    • Nov 2006
    • 25

    #2
    Originally posted by raji20
    Hello Guys,

    Hope u all are doing great. Canyou suggest me how to write a array in the cookie, for eg,

    [php]
    $var = array("1","2"," 3");

    [/php]

    Now I want to set a cookie which should store this array $var. I dont want to use for loop for storing the array value in the cookie

    Can anyone help me............

    Thanks a lot in advance
    try put it in a string and then explode it to array.
    exaple:
    [php] $var="1,2,3";
    $_SESSION['var']=$var;[/php]

    then when you want to read it.
    [php]if ($var) {
    $items = explode(',',$va r);
    }[/php]
    and $items is your array..

    Hope that helps.

    Comment

    Working...