Use Simple Values in SessionStorage
<html>
<head>
<title>Use Simple Values in SessionStorage</title>
</head>
<body>
<form>
<input type="button" value="Write Simple Values" onclick="writeSimpleValues()">
<input type="button" value="Read Simple Values" onclick="readSimpleValues()">
<br>
<div id="result"></div>
</form>
<script type="text/javascript">
function writeSimpleValues() {
var fullName = 'PMK Lab';
var age = 20;
sessionStorage.setItem('fullName', fullName);
sessionStorage.setItem('age', age);
}
function readSimpleValues() {
var fullName = sessionStorage.getItem('fullName');
var age = sessionStorage.getItem('age');
var result = 'Full Name: ' + fullName;
result += '<br>Age: ' + age;
document.getElementById('result').innerHTML = result;
}
</script>
</body>
</html>
Run Application
Open site in browser and display as below: