You are here: Web Apps with Visual LANSA > 11. Using SYS_WEB to access Browser and JavaScript Features > 11.6 Session and Local Storage

11.6 Session and Local Storage

The browser local and session storage features are available through the use of SYS_WEB.SessionStorage and SYS_WEB.LocalStorage properties.

SessionStorage and LocalStorage are physical storage areas belonging to the domain.

Using Session or Local storage is more secure than cookies and allows for large amounts of data to be stored locally without impacting performance.

The amount of data that can be stored depends entirely on the browser or device, but can be as much as 10Mb. If you intend to use browser storage features for anything beyond a small amount of data, it is recommended that you familiarize yourself with the capabilities of your target platform and devices.

* Save the supplied value in the browser local storage

Mthroutine Name(SaveValue)

Define_Map For(*Input) Class(#Prim_alph) Name(#Name)

Define_Map For(*Input) Class(#Prim_alph) Name(#Value)

 

If (#sys_web.localStorage<#Name> *Is *null)

 

#sys_web.localStorage.Add( #Name #Value )

 

Else

 

#sys_web.localStorage<#Name> := #Value

 

Endif

 

Endroutine

 

* Restore a value from the browser local storage

Mthroutine Name(RestoreValue)

Define_Map For(*Input) Class(#Prim_alph) Name(#Name)

Define_Map For(*Result) Class(#Prim_alph) Name(#Result)

 

If (#sys_web.localStorage<#Name> *IsNot *null)

 

#Result := #sys_web.localStorage<#Name>

 

Endif

 

Endroutine