SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    Colorado, USA
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Solution with cookies?

    I do not have much hand-coding scripting experience, but I was wondering how I could achieve the "Save" effect on this site http://www.tradedoubler.com/pan/index.jsp, where the visitor can select a country with "Save" checked and then the next time they visit the site, they will automatically be taken to the version of the site for the country they selected?

    Thanks for any help!
    Terri Eades - Web/Graphic Designer - www.terrieades.com

  2. #2
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, you could do it this way with PHP:

    PHP Code:
    <?php
     
    if(!(isset($_COOKIE['country']))) {
     
    $country $_POST['locale'];
     
    setcookie("country","$country",time()+"1000000","","","1");
    }
    ?>
    Name, Value, Expiration, Path, Domain, Secure

    Then you can call back the value of the cookie by using $_COOKIE['country']. So, say you want to check and see if they have already set a cookie, you could do this:

    PHP Code:
    <?php
     
    if(isset($_COOKIE['country'])) { $country $_COOKIE['country']; }
    ?>
    You would put the first piece of code on the page after you click "Go". For the second piece of code, you could run a check on the front page that, if $country is set, automatically directs the user to specified page.
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  3. #3
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    Colorado, USA
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I think this will be helpful! I just have a couple of questions on how to use this:

    1. What do I need to put within the blank quotes that are currently in the first snippet of code, if anything?
    2. Where do I define which country goes to which page? Is there a place for this?

    Thank you again for the assistance!
    Terri Eades - Web/Graphic Designer - www.terrieades.com

  4. #4
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    Colorado, USA
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anybody lend a bit of help?
    Terri Eades - Web/Graphic Designer - www.terrieades.com


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
  •