SessionStorage

SessionStorage is a key-value store of strings, where all data is removed at the end of a session (ie. when the tab or browser is closed).

Storage is typically limited to around 5Mb of data in most browsers, and can be cleared if the user requests it or if the user is running out of space.

Still, SessionStorage can be useful for things like configuration, session keys or even communication between web applications running on the same origin domain.

Common operations

get : String -> Task ReadError String

Get the value associated with a given key.

set : String -> String -> Task WriteError {}

Insert the key-value pair into the store. If the key already exist it will be overwritten. If it doesn't exist, it will be added.

remove : String -> Task AccessError {}

Remove the key-value pair from the store.

clear : Task AccessError {}

Remove all key-value pairs from the store.

Discovery

length : Task AccessError Int

Gets the number of key-value pairs in the store. You can use this to check if the store is empty, or in combination with keyAtIndex and get to read out every key-value pair that has been stored.

keyAtIndex : Int -> Task ReadError String

Let's you find the nth key in the store. Keep in mind that keys are not stored in any particular order. So calling this function with index 0 will not necessarily return the first key that was stored.