Results 1 to 4 of 4

Thread: cookie only to activate when clicked on close

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default cookie only to activate when clicked on close

    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
    Code:
    <?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
    The web in one word.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Ok, if a user clicks on a button, replace:
    PHP Code:
    <?php 
    setcookie
    ("defaultsearch""true"time()+604800);
    ?>
    With
    PHP Code:
    <?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:
    Code:
    <img src="$_COOKIE['hi']" />
    Hope this helps.
    Jeremy | jfein.net

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Suppose if you don't want to reload the page completely you can go for an AJAX based solution

  4. #4
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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
    The web in one word.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •