Session storage

Overview

Project lead: Paul Jackson (@pjackson28)

Purpose

The HTML5 Web Storage sessionStorage object is used to store data for the current session. Because some browsers do not support this functionality natively, this polyfill emulates the same functionality.

Benefits

  • In cases where a browser doesn't support sessionStorage, the polyfill is automatically loaded.

Implementation

To use the polyfill, the standard sessionStorage object must be used. In cases where browsers don't support this object, the polyfill is automatically loaded.

Example code

value = sessionStorage.getItem('variable');
sessionStorage.setItem('variable', value);

Examples

Development

Session storage functionality is dependent upon native support for the HTML5 Web Storage sessionStorage object or the sessionStorage polyfill.

Known issues

This polyfill is dependent upon cookies so will not work where cookies can't be used (e.g., viewing the page offline).

Version history

References