setSharedData
Description
Stores in-memory data that is shared globally while the app runs.
Any page or script can read the stored data with $app.getSharedData(key) for as long as the app is running. The data disappears when the app exits (non-persistent).
Pass null as data to delete that key.
Parameters
| Parameter | Type | Description |
|---|---|---|
| sharedKey | String | Key name that identifies the data |
| data | dynamic | Value to store. null deletes the key |
Returns
void
Notes
- The data lives only in the app process memory and resets when the app restarts.
- Every page shares the same memory map, so this is a good fit for passing data between pages.
- Use
$app.setStoreData()when you need persistent storage. - To change an App Variable defined in Studio, use
$app.setVar(). - No type restriction on values — strings, numbers, objects, and arrays all work.
Example
// Store user info globally after login
$app.setSharedData("currentUser", { id: 1, name: "홍길동", role: "admin" });
// Read it from another page
var user = $app.getSharedData("currentUser");
console.log(user.name); // "홍길동"
// Delete the key (on logout)
$app.setSharedData("currentUser", null);
setSharedData vs setStoreData vs setVar comparison
| Item | setSharedData | setStoreData | setVar |
|---|---|---|---|
| Storage location | App process memory | Disk (LucyStorage) | App Variable system (LucyVarMngr) |
| Persistence | Lost when the app exits | Kept after the app restarts | Lost when the app exits |
| How it's defined | Any key you choose in code | Any key you choose in code | Must be predefined in Studio |
| Read function | $app.getSharedData(key) | $app.getStoreData(key) | $app.getVar(name) |
| How to delete | Pass a null value | Pass a null value | Value changes only |
| Main use | Temporary data sharing between pages | Persistent storage for user settings, login tokens, and more | Controlling App Variables wired to the Studio UI |
| Speed | Fast (memory) | Relatively slow (disk I/O) | Fast (memory) |
When to use which
- Session data, passing values between pages →
setSharedData— fast and simple, cleared automatically when the app exits - Settings, login state, favorites →
setStoreData— when values must survive an app restart - Updating Studio UI variables →
setVar— only variables declared in advance in Studio can change
Related
$app.getSharedData(sharedKey)$app.setStoreData(key, data)$app.getStoreData(key)$app.setVar(appVarName, data)$app.getVar(appVarName)