Reputation: 9499
Is there a way to have something similar to a web session in c#?
For example if I set a integer somewhere integer id = 5;
Could I access that integer at a later time in a different class?
I am writing an app that communicates with a web service and I need to keep the id of the authenticated user around for queries to the web.
Or is my best option to use a database and store the id and access it from the database when needed.
Upvotes: 0
Views: 95
Reputation: 13273
Simply enough.
No need for a database. If the only thing that needs to persist is a simple ID, you can save it in a binary file, xml file or plain text.
The best equivalent to session variables I can think of is :
By the way, the C# type is int
Upvotes: 2