> 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/jentis-dcp-elements/variables/server-side-variables-backend/use-cases-for-server-side-variables.md).

# Use Cases for Server Side Variables

Server-side variables can access all the details of the server-side environment, including the local storage on the virtual machine or any value that is submitted from the client-side to your JENTIS server.

### Read and Write Local Storage Properties

With the following server-side variable, you can access an event's property, check the value, and return a result based on it. For this, local storage is very helpful, which can hold information for later use. One example might be a situation where you want to deduplicate transactions that are tracked in your frontend. Sounds interesting? Here is a detailed guide on implementing a server-side deduplication function with server-side variables.

The basic syntax of server-side variables follows this general template:

{% code lineNumbers="true" %}

```javascript
async function(){
  var storage_value = await this.storage.read("storage_name");
  
  this.storage.write("storage_name", "updated value", Date.now()+94608000000);
}
```

{% endcode %}

### Server-Side to Client-Side variable references

This feature enables users to access the value of another client-side variable within a client-side variable. As a result, it is possible to reuse values from existing variables. Furthermore, even references of references of references are achievable.

The reference functionality can be used like this:

{% code lineNumbers="true" %}

```javascript
this.getFrontendVariable("<ID of client-side variable>");
```

{% endcode %}

The ID of a variable can be found in the edit view of the JTM in the property field “ID”.\\

<figure><img src="https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2Fgit-blob-c496fb29999855397b140bca2947a27a88afeaad%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
It is important to note that this functionality only works with the JENTIS wrapper scripts we provide.
{% endhint %}

Full client-side variable example for gathering the screen resolution:

{% code lineNumbers="true" %}

```javascript
async function() {
    return this.getFrontendVariable("window_screen_width") + " x " + this.getFrontendVariable("window_screen_height");
}
```

{% endcode %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.jentis.com/jentis-dcp-elements/variables/server-side-variables-backend/use-cases-for-server-side-variables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
