Computer >> Computer tutorials >  >> Programming >> Javascript

How to show name/value pairs of cookies in a document with JavaScript?


To show the name/value pair of cookies, use the cookie property. You can try to run the following code to display name/ value pairs of cookies in a document with JavaScript −

<!DOCTYPE html>
<html>
   <body>
      <script>
         var val = document.cookie;
         document.write("<br>Name/ Value pair of Cookies: "+val);
      </script>
   </body>
</html>