Use Object in SessionStorage in HTML5


<html>
    <head>
        <title>Use Object List in SessionStorage</title>
    </head>
    <body>

        <form>
            <input type="button" value="Write Object" onclick="writeObject()">
            <input type="button" value="Read Object" onclick="readObject()">
            <br>
            <div id="result"></div>
        </form>

        <script type="text/javascript">

            function writeObject() {
                var product = {
                    id: 'p01',
                    name: 'name 1',
                    price: 20
                };
                sessionStorage.setItem('product', JSON.stringify(product));
            }

            function readObject() {
                var account = JSON.parse(sessionStorage.getItem('product'));
                var result = 'Id: ' + account.id;
                result += '<br>Name: ' + account.name;
                result += '<br>Price: ' + account.price;
                document.getElementById('result').innerHTML = result;
            }

        </script>
    </body>

</html>




Open site in browser and display as below: