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:
Warning: setcookie() expects parameter 2 to be string, array given in C:\xampp\htdocs\folder\sajjad.php on line 3.
I already tried all the answers available in StackOverflow regarding this topic. But none of them are working.
<?php
$val = array('1','2','3','4');
setcookie("sajjad",$val,time()+(86400*30));
?>
<!DOCTYPE html>
<html>
<head>
<title>HOME</title>
</head>
<body>
</body>
</html>