# Variables

## Variables used

A variable has to be created before the application is published. After an application has been published in Qlik Sense Server, only session variables can be created. A session variable lives and dies within the session.

Information noteSession variables are never listed in VariableList.

### Create

* CreateVariableEx

### Get

* GetVariableById

* GetVariableByName

* GetVariableList

### Destroy

* DestroyVariableById

* DestroyVariableByName

### Session Variables

* CreateSessionVariable

* DestroySessionVariable

## Scenario:

Example:

```
private IVariable CreateVariable(IApp myApp)
{
	return myApp.CreateVariableExpression(null,new VariableProperties
	{
		Name = "Sales2012",
		Definition = @"=Year(Today())-3"
	});
}
```

Example:

```
private IVariable CreateSessionVariable(IApp myApp)
{
	return myApp.CreateSessionVariable(null, new VariableProperties
	{
		Name = "Sales2011",
		Definition = @"=Year(Today())-4",
	});
}
		
```

## The following variables are obsolete and will be removed within a year

* CreateVariable

* GetVariable

* RemoveVariable

* SetFavoriteVariables

* GetFavoriteVariables

## Learn more

* [Creating a variable using the variables dialog](https://help.qlik.com/en-US/sense/November2025/Subsystems/Hub/Content/Sense_Hub/Variables/create-variable-using-dialog.htm)