www.webdeveloper.com
Results 1 to 3 of 3

Thread: Cookies - Javascript

  1. #1
    Join Date
    Jul 2009
    Posts
    73

    Exclamation Cookies - Javascript

    I will start with i don't have a clue......im trying to right a cookie that displays a DIV once a day for the user. I'm completely lost when it comes to cookies. i don't know if i wright the code for the div in the set cookie or in the get cookie section. I don't know....if someone could help me i would appreciate it very much. i would even appreciate any direction on where i can learn STEP BY STEP on how to create cookies even video's.

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,125
    Here's a basic example using jQuery cookies:
    http://jsfiddle.net/dfreema1/9Q4wC/7/

    The div should display the first time you access the page, but if you press run, it should disappear because you already saw it today. It won't show up again for 1 day. You can test it by deleting the cookie, then pressing run again.
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  3. #3
    Join Date
    Jul 2009
    Posts
    73
    Now that is a great example......now can you show me how to wright it in straight JavaScript. i know that JScript is support to have many short cuts but i would like to learn how to do it in straight Javascript. If you wouldn't mind taking a look at what i have thus far...

    This is me trying to Set the cookie...
    I'm stuck on how to create the cookie string. I know i need to enter the expiration date but can't tell the right syntax to use. And i want the Experation date day to day.
    Code:
    function setCookie(name, value, expDate)
    {
     document.cookie = name + "=" + value
    }
    I found this site which kinda gives a step by step approach.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles