save cookies to the array and then print

Asked

Viewed 16 times

0

Here’s what I’m trying to do: Every time he click on the button, the counter counts + 1, and this amount will be used in foreach for him to save in cookies. look at my code:

$contar = 0;

if(isset($_POST['submit'])){
  $contar = $contar + 1;
}

if (isset($_POST['ideia'])) {
  


$cookie_value= $_POST['ideia'];
foreach ($contar as $id) {

 setcookie('text['.$id.']',$cookie_value,time()+36000);
}

}

  • Doesn’t explain what problem you’re having

  • look here the problem, I want to do what I explained but it is showing error, this error here Warning: Invalid argument supplied for foreach()

  • In the future put the mistakes you are getting to facilitate the work of those who are helping you, put the error in your question by editing it,.

1 answer

0


Browser other questions tagged

You are not signed in. Login or sign up in order to post.