...

View Full Version : Cookie issue - help requested



exzrael
08-31-2007, 05:47 PM
I'm able to set a cookie but unable to read the value later on; here is the code ..

Page 1: This code checks if a cookie named tipsare is present. If so, it collects the value and $tipsarens get that value. Later, a textbox will have that value of $tipsarens.



<?
if (isset($_COOKIE['tipsare']))
{
$tipsarens = $_COOKIE['tipsare'];
}
else
{
$tipsarens = "No cookie saved (to check if the cookie is there)";
}
?>


Page 2: This code takes the value from a textbox (thus $_POST) and if no cookie named tipsare is present, it will create one and add a value to it from $_POST['vemskrev'].



<?
$tipsnamn = $_POST['vemskrev'];
if (!isset($_COOKIE['tipsare']))
{
setcookie('tipsare', '$tipsnamn', time() + 2592000);
}
?>


Now, I can't get the code to work. It shows the value $tipsnamn instead of the wanted value. How can I this to work. All help is appreciated. $_POST['vemskrev'] is the value from a textbox.

// Daniel

Nightfire
08-31-2007, 05:50 PM
setcookie('tipsare', $tipsnamn, time() + 2592000);

exzrael
08-31-2007, 06:28 PM
That was embarrasing to the max. Thanks for pointing out that simple error.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum