Skip to content

TWebLocalStorage

TWebLocalStorage is a component that can be used to access local browser storage. The storage is handled by the browser and coupled to the specific URL of the web application. From another URL, this local storage is not accessible. The TWebLocalStorage can be considered as a key/string value pair storage. With the class TWebLocalStorage it is easy to use.

Example:

var
 LLocalStorage: TWebLocalStorage
 LLocalStorage := TWebLocalStorage.Create;
 LLocalStorage.Values[mykeyname] := myvalue;
 LLocalStorage.Free;
Or alternatively, you can also use the static method that reduces this code to:
 TWebLocalStorage.Values[mykeyname] := myvalue;
When the same URL is visited by the browser, the values stored from the last session can be retrieved. The TWebLocalStorage has an event OnChange. This event is triggered when the local storage of the app is modified in another browser document instance.