Thanks to this recipe, you'll know how to use sessionStorage
to store properties with values. It's very important to keep in mind the lifecycle of these properties. If the user closes the browser or cleans the HTTP session, our values stored in sessionStorage
will be deleted.
The application for this recipe shows you how to store and read one property in sessionStorage
. We are going to start by setting and displaying a property called today
, which stores the current date using a format based on the value of another property set previously in localStorage
. As you've seen in the previous recipe, lang
is a property storing the language selected by the user. In this recipe, our application will read this property from localStorage
and will set the suitable format for the today
property based on it. For example, if the current date is June, 13th 2011 and the selected language is English, the value for today
will be 6/13/2011. Otherwise, the result will be 13/6/2011.