cookies problem
| From: | Ross | Date: | Thu, 15 Sep 2005 09:13:34 +0000 |
| Subject: | cookies problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-222466@lists.php.net to get a copy of this message | ||
I am very close to getting this sorted.....Thanks for all the help on
'variable variables' and var_dump. Two useful techniques.
My function works but throws up a cookie problem
if (isset($add)){
${$add} = intval($_COOKIE['cookie'][$add]);
$new= $$add+1;
setcookie("cookie[$add]", "$new $add");
echo var_dump($_COOKIE['cookie'][$add]);
}
At the beginining of my page I have...
session_start();
require_once('init_cookies.php');
Init_cookies is jus a for loop to initialise the cookies...
$dishes= array ("pakora", "haggis_fritter");
for ($i=0; $i < 2; $i++){
setcookie("cookie[$dishes[$i]]", "0 $dishes[$i]");
when I leave it in it resets the cookies when they are sent to the page.
When I take it out the headers already sent error occurs. I do not know if
this is my lack of undertanding of require_once/include_once.
I need a way to initialise the cookies one time only. I have tried an 'if
(isset)' but that doesn't work.
thanks again....
Ross