title: Storing Array in a cookie
body: <p>I want to store an array into a cookie using the set_cookie() function. So whenever I pass an array as an argument to the set_cookie() function it returns an error:</p>
  
  <blockquote>
    <p>Warning: setcookie() expects parameter 2 to be string, array given in C:\xampp\htdocs\folder\sajjad.php on line 3. </p>
  </blockquote>
  
  <p>I already tried all the answers available in StackOverflow regarding this topic. But none of them are working.</p>
  
  <pre><code>&lt;?php  
      $val = array('1','2','3','4');
      setcookie("sajjad",$val,time()+(86400*30));
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;HOME&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>