title: How to remove certain characters using cookies?
body: <p>I'm trying to print the cookies that I have stored. For example, if I enter John Smith then it should look like:</p>
  
  <pre><code>Welcome John Smith
  </code></pre>
  
  <p>However, when it prints it looks like this:</p>
  
  <pre><code>Welcome firstname=John lastname=Smith
  </code></pre>
  
  <p>I don't know how to get rid the cookiename and the sign <code>=</code>. I tried to use substring string, but it only prints firstname= then the actual name is discarded.</p>
  
  <pre><code>&lt;form method="post" onsubmit="return savecookies()" autocomplete="on"&gt;
        &lt;div class="sep"&gt;
          &lt;h1 class="header"&gt;Welcome &lt;span id="greetings"&gt;&lt;/span&gt;&lt;/h1&gt;
        &lt;/div&gt;&lt;br&gt; Firstname
        &lt;br&gt;
        &lt;input type="text" name="fname" id="fname" pattern="[A-Za-z\-]+" maxlength="25" required placeholder="Enter first name" autofocus&gt;&lt;br&gt; Lastname
        &lt;br&gt;
        &lt;input type="text" name="lname" id="lname" pattern="[A-Za-z\-]+" maxlength="25" required placeholder="Enter last name"&gt;&lt;br&gt;
        &lt;input type="submit" onclick="savecookies(); return false;" value="Submit"&gt;
        &lt;/div&gt;
  &lt;/form&gt;
  
   function savecookies() {
        var fname = document.getElementById("fname").value;
        setCookie("firstname", fname, 1);
  
        var lname = document.getElementById("lname").value;
        setCookie("lastname", lname, 1);
      }
  
  function setCookie(cookieName, cookieValue, length) {
    var date = new Date();
    date.setTime(date.getTime() + (length * 24 * 60 * 60 * 1000));
    var expires = "expires=" + date.toGMTString();
    document.cookie = cookieName + "=" + cookieValue + ";" + expires + ";path=/";
  }
  
  function getCookie() {
    var decodedCookie = decodeURIComponent(document.cookie);
  
    var ca = decodedCookie.split(';');
    var msg = "";
    for (var i = 0; i &lt; ca.length; i++) {
      var c = ca[i];
    }
    var msg = ca[1] + " " + ca[2];
    document.getElementById("greetings").innerHTML = msg;
    return "";
  }
  </code></pre>