cookies problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux