> For the complete documentation index, see [llms.txt](https://docs.jentis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jentis.com/developer-guide/codeblocks/public-function-scope/getlocalstorageitem.md).

# getLocalStorageItem

## `this.getLocalStorageItem` Function

#### Description

With this method, a value previously stored in the browser’s **localStorage** can be retrieved. The function also checks whether the stored item has expired (based on its TTL) and automatically removes it if expired.

If the item is still valid, its expiration time is **renewed**, keeping it active for the same TTL duration again.

***

#### Parameters

| Name  | Type     | Description                                               |
| ----- | -------- | --------------------------------------------------------- |
| `key` | `String` | The key under which the item is stored in `localStorage`. |

***

#### Returns

| Type           | Description                                                                        |
| -------------- | ---------------------------------------------------------------------------------- |
| `Any` / `null` | Returns the value if the item exists and is not expired, otherwise returns `null`. |

***

#### Usage Example

```javascript
var value = this.getLocalStorageItem("my_test_key");
```

Retrieves the value previously stored under the key `"my_test_key"`.\
If the item exists and is still valid (not expired), the value is returned. Otherwise, `null` is returned.

***

#### Important Notes

* If the item is not found or has expired, the function returns `null`.
* If the TTL or expiry is missing (e.g., due to older format), the function will apply the current system default TTL.
* When a valid item is returned, its **expiration is updated**, extending its validity.
* The function checks if `localStorage` is available using `jentis.helper.bIsLocalStorageAvailable`.
* Do not use this function inside nested functions where the `this` context might be lost.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.jentis.com/developer-guide/codeblocks/public-function-scope/getlocalstorageitem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
