How to install a cookie onto my website ?

Discussion in 'Web Design and Development' started by fab5freddy, Aug 26, 2009.

  1. fab5freddy macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #1
    Hi There, Does anyone know how to install a cookie onto my website ?

    I would like to put a cookie onto my website,
    so that all visitors that come to my website get my cookie
    on their computer, so that when they come back it remembers
    their settings.

    Any help would be appreciated ;-)

    thanks!
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    JavaScript can create cookies. It'll just depend on what "settings" you're trying to save. Your code will need to save those settings as well as read them from the cookie when they return. PHP and other languages can too I'm fairly certain, but have only dealt with them from JavaScript.
     
  3. fab5freddy thread starter macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #3
    yeah, i believe php will do the trick.

    but i have to read up some more on that.

    If anyone knows, please chime in......

    thanks!
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
  5. Joined:
    Jun 30, 2009
    #5
    Just my ¢2, but I find the code for PHP cookies to be cleaner than JavaScript's.
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    Yea, that's very likely. I never feel overly comfortable when I'm doing it with JavaScript, but I have settings that get set during page interactions so it's a little more straight forward to save them there. I suppose I could offload it to a PHP script via AJAX though.
     

Share This Page