Web Local Storage (PRIM_WEB.LocalStorage)

Access to the browser local storage

Ancestors - Object (PRIM_OBJT)

Details

LocalStorage is the browser's persistent data storage area, consisting of a set of name/value pairs, and is ideal for storing data such as user names and encrypted passwords.

LocalStorage is per domain meaning that all web pages can access the same set of data. The amount of data that can be stored depends on the browser and device but is typically in the order of 5Mb or more.

Storage items can be accessed directly via their Key or by iterating over the collection.

Example

This example shows how you might save a password. Note the use of the Encrypt intrinsic function to protect the stored value.

     If (#sys_web.localStorage<Password> *Is *null) 
        #sys_web.localStorage.Add( Password #Password.Encrypt(Key)) 
     Else 
        #sys_web.localStorage<Password> := #Value.Encrypt(Key) 
     Endif 

This example shows how you might restore a password. Note the use of the Decrypt intrinsic function.

     If (#sys_web.localStorage<Password> *IsNot *null) 
        #Password := #sys_web.localStorage<Password>.Decrypt(Key) 
     Endif 

You can also iterate over the LocalStorage items.

     For Each(#StorageItem) In(#sys_web.LocalStorage) 
        #Com_owner.AddEntry( #StorageItem.Name #StorageItem.Value ) 
     Endfor

Properties

Name

Description

Available

True if the LocalStorage features of the browser are available

ComponentClassName

ComponentClassName is the name of the component's class. Inherited from Object (PRIM_OBJT)

ComponentMembers

ComponentMembers provides access to all the member components of this component Inherited from Object (PRIM_OBJT)

ComponentPatternName

ComponentPatternName is used to qualify the class of the component. Inherited from Object (PRIM_OBJT)

ComponentTag

Generic space allowing a value to be stored for the instance Inherited from Object (PRIM_OBJT)

ComponentType

ComponentType gives you access to the type information about the component Inherited from Object (PRIM_OBJT)

ComponentTypeName

ComponentTypeName is the fully qualified name of the component's class. Inherited from Object (PRIM_OBJT)

Item

Provides access to a particular item in a collection

ItemCount

Number of LocalStorage items

Name

Name identifies the component Inherited from Object (PRIM_OBJT)

Owner

Owner owns this component Inherited from Object (PRIM_OBJT)

Parent

The component instance to which this instance is attached. The visual container for a control or the collector of a set of child instances Inherited from Object (PRIM_OBJT)

Events

Name

Description

CreateInstance

CreateInstance is signalled when an instance of a component is created Inherited from Object (PRIM_OBJT)

DestroyInstance

DestroyInstance is signalled when an instance of a component is about to be destroyed Inherited from Object (PRIM_OBJT)

Methods

Name

Description

Add

Add an name | value pair item

Key, Value

Clear

Clear local storage

CreateIterator

CreateIterator method creates an iterator component that enables iteration through the collection

Result

Remove

Remove an item

Key


See also

All Component Classes

Technical Reference