Hello.
I have a small problem.
I know that setcookie must be sent before all <html> or <head> headers.
I have an search form, and option there to remember search settings for future visits.
Then, when form is Submitted, it redirects user to (for example) results.php page, on wich I put on top of it a setcookie to collect variables with $_POST. It is like this:
<?php
if (@isset($_COOKIE['b_s']))
{
}
else
{
/* one year cookie*/
setcookie ("b_s", $_POST['D1']." ".$_POST['sel']." ".$_POST['category']." ".$_POST['country']." ".$_POST['state']." ".$_POST['city'], time()+24*60*60*100);
}
?>
But... I get <headers allready sent error> when I compile it.
Does this $_POST superglobal have to do something with it, should I use $_GET or what?
Even if I put only this line on the top:
setcookie ("b_s", $_POST['D1']." ".$_POST['sel']." ".$_POST['category']." ".$_POST['country']." ".$_POST['state']." ".$_POST['city'], time()+24*60*60*100);
I still get the same result.
I would like those Posted values to be passed to my cookie value.
Note: When I use both above codes without $_POST (I mean when I put for cookie value something like: "1 2 5 6 7 8"
it works ok.
Thanks for any suggestions.
I have a small problem.
I know that setcookie must be sent before all <html> or <head> headers.
I have an search form, and option there to remember search settings for future visits.
Then, when form is Submitted, it redirects user to (for example) results.php page, on wich I put on top of it a setcookie to collect variables with $_POST. It is like this:
<?php
if (@isset($_COOKIE['b_s']))
{
}
else
{
/* one year cookie*/
setcookie ("b_s", $_POST['D1']." ".$_POST['sel']." ".$_POST['category']." ".$_POST['country']." ".$_POST['state']." ".$_POST['city'], time()+24*60*60*100);
}
?>
But... I get <headers allready sent error> when I compile it.
Does this $_POST superglobal have to do something with it, should I use $_GET or what?
Even if I put only this line on the top:
setcookie ("b_s", $_POST['D1']." ".$_POST['sel']." ".$_POST['category']." ".$_POST['country']." ".$_POST['state']." ".$_POST['city'], time()+24*60*60*100);
I still get the same result.
I would like those Posted values to be passed to my cookie value.
Note: When I use both above codes without $_POST (I mean when I put for cookie value something like: "1 2 5 6 7 8"

Thanks for any suggestions.