In ye olde days, cookies were used to store data (temporarily) on a web user's computer; nowadays, the Web Storage API (small key-pair data strings) and the IndexedDB (more complicated data) are the ways to accomplish this. This example is a very simple example of using the Web Storage API. Here's what the entire two pages look like (see bottom of page for absolute simplest example):
This page will store the values entered above. Click on the Read and Display link to see that we can read these data items.
For the absolute simplest example:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<p>Blah blah blah this is the main text body of the html page.</p>
<script>
// This stores the text string "simple example" as a key-pair associated with "name".
localStorage.setItem('name', "simple example");
// And this reads it back into a constant, where you can do stuff with it.
const my_stored_name = localStorage.getItem('name')
</script>
</body>
</html>
After creating the absolute simplest example, you can see that the key-pair is actually being saved by looking in your browser tools. For example, with Firefox, press F12 to open the tools window, then click on the "Storage" tab, then "Local Storage", then the web-page's name, then you'll see the key-pair in the right-hand pane.