The previous answer is how you should save the values that affect the whole app: using a public property in the Program class. but since these are user variables for a whole desktop application I would create a structure or a dictionary to store all the session variables within a single object, this will help you learn how to use the session variables in an environment of web programming.
Dictionaries
in the Program class
Public Dictionary Session <string,dynamic > = new Dictionary<string,dynamic>()
From anywhere in your app
Program.Session["ID"] = TuUsuario;
I use the dynamic type because in it you can store any type of data, be it string, int, etc. although you must be careful when reading it because the conversion is implicit so you can face that your data types are not compatible.
If you do not want the implicit conversion you can go directly by object, but you will have to cast all the variables when you want to invoke them.
Public Dictionary Session<string,object> = new Dictionary<string,object>()
If you are not interested in keeping the original data type, you can use just a string dictionary
Public Dictionary Session <string,string> = new Dictionary<string,string>()
The problem of the latter will be the conversion of complex data types such as hours or bytes.
Advantages: you do not need to declare or instantiate any other object, only
Program.Session["<<Nombre de llave>>"] = valor
to create a new stored variable, if the key name already exists it will be updated.
on the other side are the structs
the structs are easier to manage because they limit their use to only those that are defined in the structure, in this way you will not have problems in knowing if your data is correct, they are easier to serialize and very efficient with LINQ for populate them
public static struct Session
{
public int IDUsuario;
public string NombreUsuario;
}
Program.Session.IDUsuario=5;
Program.Session.NombreUsuario="Yo";