The solution is to stringify the object before calling setItem on the sessionStorage.
var user = {'name':'John'};
sessionStorage.setItem('user', JSON.stringify(user));
var obj = JSON.parse(sessionStorage.user);
More Related Contents:
- HTML5 Local storage vs. Session storage
- browser sessionStorage. share between tabs?
- Set a default parameter value for a JavaScript function
- State not updating when using React state hook within setInterval
- How can I pass variable into an evaluate function?
- Promise – is it possible to force cancel a promise
- Accessing nested JavaScript objects and arrays by string path
- How do I get the information from a meta tag with JavaScript?
- getElementById() returns null even though the element exists [duplicate]
- How can I get selector from jQuery object
- How to check if an element is overlapping other elements? [duplicate]
- JavaScript KeyCode vs CharCode
- react useEffect comparing objects
- AngularJS – UI Router – programmatically add states
- iOS 7’s blurred overlay effect using CSS?
- Asp.Net Mvc Url.Action in external js file?
- Difference between var and this in Javascript functions?
- Reverse Scrolling
- How do I get an element to scroll into view, using jQuery?
- Unraveling Angular 2 book, Chapter 1, Example 5
- Is it possible to execute JSX scripts from outside ExtendScript?
- Why is Math.pow(0, 0) === 1?
- Delete from array in javascript
- How to Transpose / Rotate Multi-dimensional Array?
- async/await inside arrow functions (Array#map/filter)
- Sorting a list by data-attribute
- AngularJS: ng-if not working in combination with ng-click?
- Is there an equivalent of canvas’s toDataURL method for SVG? [closed]
- Difference between ( for… in ) and ( for… of ) statements?
- Maximum Call Stack Size Exceeded During a setTimeout Call