Log in

View Full Version : cookie only to activate when clicked on close



queerfm
03-28-2008, 11:14 AM
Hi my site has a cookie on it that i would like to set to an image, i would like it if a user clicks on the close button then the cookie would be set, Other wise the cookie does not become active

Here is the code i have


<?php
setcookie("defaultsearch", "true", time()+604800);
?>



<?php
if (isset($_COOKIE["defaultsearch"]))
echo "";
else
echo "<div id='icePage_SearchBoxTop_IE7DownloadControl_AddToolbar' class='iE7TBDownload'><img src='http://twitoosearch.com/images/defsearch.png' id='icePage_SearchBoxTop_IE7DownloadControl_DwldImageWrapper' usemap='#ie7_search_Map' alt='Twitoosearch bar' style='margin: 0pt; padding: 0pt;' border='0' height='250' width='1024' /><map id='ImageMap' name='ie7_search_Map'><area shape='rect' alt='Add It Now!' coords='0, 0, 972, 249' href='#' onclick='setDefaultSearch();' /><area shape='rect' alt='Add It Now!' coords='972, 0, 1023, 227' href='#' onclick='addSearch('setDefaultSearch();' /><area shape='RECT' alt='Close X' coords='972, 227, 1023, 249' href='#' onclick='closeOption();return false' /></map></div>
";
?>


If you can help that would be great

Nile
03-28-2008, 11:43 AM
Ok, if a user clicks on a button, replace:


<?php
setcookie("defaultsearch", "true", time()+604800);
?>

With


<?php
if(isset($_POST['submit'])){
setcookie("defaultsearch", "true", time()+604800);
}
?>

In case you didn't know replace submit with the name of the button. Then to set the cookie with an image inside I think that you would like to put the image path for the value of the cookie, in this way you can make the cookie act like an image, just put:


<img src="$_COOKIE['hi']" />

Hope this helps.

codeexploiter
03-28-2008, 12:12 PM
Suppose if you don't want to reload the page completely you can go for an AJAX based solution

queerfm
03-28-2008, 03:00 PM
Ok maybe i should be more clear as i don't understand how to intergrate this in, i am using map to link. I would like it if they select close
It sets the cookie - onclick='closeOption();return false'
also if they click on this
onclick='setDefaultSearch();' after they have clicked it it also activates the cookie