www.webdeveloper.com
Results 1 to 4 of 4

Thread: JS cookies

  1. #1
    Join Date
    Jun 2013
    Posts
    3

    JS cookies

    Hey guys, I need help with this simple thing, I am new to js but not entirely to web design.

    I have task to make two values like this




    document.cookie =
    'partizan=pogodak; expires=Sat; path=/'

    document.cookie =
    'zvezda=promasaj; expires=Sat; path=/'




    And now html thing, two buttons or drop down menu with this two values, partizan and zvezda

    After person click on partizan for example cookie should be stored with value pogodak and next time person come to page, it will get message pogodak and redirect to some other page, not important atm, and cookies should expire on first Saturday.

    Thanks in advance.

  2. #2
    Join Date
    Jun 2013
    Posts
    3
    bump

  3. #3
    Join Date
    Sep 2008
    Location
    Jackson MS
    Posts
    374
    Be sure value and c_name are defined and have a value
    Code:
       var exdate=new Date();
       var dayWeek = exdate.getDay();
       var expiredays = 6 - dayWeek;
       if (expiredays == 0) expiredays = 6;  //If today is Saturday, kill it next Saturday.
       exdate.setDate(exdate.getDate()+expiredays);
       document.cookie=c_name+ "=" + value + ";expires=" + exdate.toUTCString());
    should fly.

  4. #4
    Join Date
    Jun 2013
    Posts
    3
    thank u for reply, can u give me example of html too, idk how to make 2 selections with 2 cookies

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