title: Keep Time Value after closing the browser and calls it again - Javascript?
body: <p>I asked yesterday about saving a timer value when the browser closes and then start counting again when the user opens it. I've found that using cookies must be a good solution, so i've added the set and getcookie functions, but still i can't get my timer values. This might be easy, but i cant see what's wrong because i'm still too noob in javascript.
  Does someone know what i'm doing wrong?
  thank you!!
  here's the code i have so far:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;&lt;head&gt;
      &lt;title&gt;Test&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
  var sec = 0;
  var min =  0;
  var hr = 0;
  var dias = 0;
  var bool = true;
  function stopwatch() {
          sec++;
          if (sec == 60) {
              sec = 0;
              min += 1;
          }
  
          if (min == 60) {
              min = 0;
              hr += 1;
          }
  
          if (hr == 24) {
              hr = 0;
              dias += 1;
          }
  
          totalTime = ((dias&lt;=9) ? "0" + dias : dias) + "d, " + ((hr&lt;=9) ? "0" + hr : hr) + " : " + ((min&lt;=9) ? "0" + min : min) + " : " + ((sec&lt;=9) ? "0" + sec : sec);
          document.getElementById("timer").innerHTML = totalTime;
          if (bool == true) {
          start = setTimeout("stopwatch()", 1000);
  
          }
      }
  
  function setCookie(name, value, expires) {
  document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString());
  }
  
  
  
  function getCookie (name) {
      var cname = name + "=";               
      var dc = document.cookie;
  
      if (dc.length &gt; 0) {              
          begin = dc.indexOf(cname);       
              if (begin != -1) {           
              begin += cname.length;       
              end = dc.indexOf(";", begin);
                  if (end == -1) end = dc.length;
                  return unescape(dc.substring(begin, end));
              } 
          }
      return null;
  }
  
  
  var exp = new Date();                                  
  exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30));
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="stopwatch()"&gt;
      &lt;div id="timer" name="timer"&gt; &lt;/div&gt;
    &lt;button onclick="bool = false"; &gt; pause &lt;/button&gt;
    &lt;button onclick="bool = true;stopwatch();" &gt; resume &lt;/button&gt;
  
      &lt;form&gt;
        &lt;input type="button" value="Set a Cookie" onClick="setCookie('myCookie',timer.value, exp)"&gt;
      &lt;/form&gt;
  &lt;form&gt;
  &lt;input type="button" value="Get Cookie Value" onClick="this.form.tf.value = getCookie('myCookie')"&gt;
  &lt;input type="text" name="tf" size="30"&gt;
  &lt;/form&gt;
  
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>