Hello Friends,
Finally, a big thx to Hayri ASLAN, who corrected my code.
Thank you to everyone who participated in this topic : Paul, Sherzod and Hayri
For those who are interested
//**********************************************************************
// METHODE without define (JavaScript Code) on Main > Script
// Big Thx to Hayri ASLAN [Unigui Forum 24/04/2019]
// Benefict to Use LocalStorage instead of Cookies :
// 10 Mo Persistent data on Client Side (even with Refresh browser)
// Only strings are store
//**********************************************************************
//1. To Set the Key 'K1'
procedure TMainForm.UniButton1Click(Sender: TObject);
var st:string;
begin
st:=UniEdit1.Text;
UniButton1.JSInterface.JSCallGlobal('localStorage.setItem', ['K1', st] ); // Key , Value (always string)
end;
//2. To retreive Value of 'K1' on UniEdit2
procedure TMainForm.UniButton2Click(Sender: TObject);
begin
with UniEdit2.JSInterface do
JSCall('setValue', [jsstatement('localStorage.getItem("K1")')]); // important : Key must be Quoted " "
end;
//3. To remove Key 'K1'
procedure TMainForm.UniButton3Click(Sender: TObject);
begin
UniButton3.JSInterface.JSCallGlobal('localStorage.removeItem', ['K1']);
end;
All the Best
LocalStorage2.zip