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

NameDescription
AvailableTrue if the LocalStorage features of the browser are available
ComponentClassNameComponentClassName is the name of the component's class. Inherited from Object (PRIM_OBJT)
ComponentMembersComponentMembers provides access to all the member components of this component Inherited from Object (PRIM_OBJT)
ComponentPatternNameComponentPatternName is used to qualify the class of the component. Inherited from Object (PRIM_OBJT)
ComponentTagGeneric space allowing a value to be stored for the instance Inherited from Object (PRIM_OBJT)
ComponentTypeComponentType gives you access to the type information about the component Inherited from Object (PRIM_OBJT)
ComponentTypeNameComponentTypeName is the fully qualified name of the component's class. Inherited from Object (PRIM_OBJT)
ItemProvides access to a particular item in a collection
ItemCountNumber of LocalStorage items
NameName identifies the component Inherited from Object (PRIM_OBJT)
OwnerOwner owns this component Inherited from Object (PRIM_OBJT)
ParentThe 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

NameDescription
CreateInstanceCreateInstance is signalled when an instance of a component is created Inherited from Object (PRIM_OBJT)
DestroyInstanceDestroyInstance is signalled when an instance of a component is about to be destroyed Inherited from Object (PRIM_OBJT)

Methods

NameDescription
AddAdd an name|value pair item
Key, Value
ClearClear local storage
CreateIteratorCreateIterator method creates an iterator component that enables iteration through the collection
Result
RemoveRemove an item
Key

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2