Results 1 to 2 of 2

Thread: to save cookies for 6 months

  1. #1
    Join Date
    Dec 2017

    to save cookies for 6 months

    ypo: cdate should be date.

    Double access of .value.

    var name = document.getElementById("name").value;
    // ...
    var textvalue = name.value;

    See how you accessed .value twice?

  2. #2
    Join Date
    Mar 2007
    When posting code, use the forum BB Code tags (as shown in my signature)
    var name = document.getElementById("name").value; 
    // ...
    var textvalue = name.value;
    1. avoid using reserved or key words to avoid problems in your code call it something that sets it apart from keywords and reserved words.
    2. cookes should be avoided, they are not reliable can be deleted / expired without your intervention as well as hijacked!

    var username = document.getElementById("name"); // get the object incase you want access to other properties 
    // ...
    var textvalue = username.value; // make the variable equal to the property of value.
    Use a localStorage object to store the future date then on page load you can refer to this to see if the time is up. You can find out more by searching for localStorage object (part of the improvements in HTML5 browsers)

    Then only use the cookie method as a fallback if localStorage is not supported.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

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