For Local Use...

Define a persistent value

To define a value that persists between kernel sessions, use PersistentValue:

Out[1]=

Use a persistent value

Use a persistent value as you would any symbol:

In[2]:=
Click for copyable input
Out[2]=

The persistent value is not lost when the kernel is restarted:

In[4]:=
Click for copyable input

Remove a persistent value

In[6]:=
Click for copyable input

For Use Both on the Desktop and in the Cloud...

Define a persistent value

To define a value that persists between kernel sessions and can be used both on the desktop and in the cloud, put the value in the Cloud persistence location:

Out[7]=

Use a persistent value

Use a persistent value as you would any symbol. Both desktop and cloud have access to the same persistent value:

In[8]:=
Click for copyable input
Out[8]=

The persistent value is not lost when the kernel is restarted:

In[10]:=
Click for copyable input

Remove a persistent value

In[12]:=
Click for copyable input

Notes

Persistent values defined in the default location in Wolfram Cloud are not available on the desktop and vice versa.