PDA

Click to See Complete Forum and Search --> : [2.0] Is there a session variable in c #?


JenniferBabe
Jun 16th, 2007, 01:15 PM
Hi. Just want to know if there is a session variable in C# similar to that in PHP. In php there a session variable that once set, any other class could access that variable directly and also update values to that variable until it is destroyed.

Is that anything similar to that in C#?

Jennifer.

penagate
Jun 16th, 2007, 02:01 PM
Yes:
Session["variable"] = value;

JenniferBabe
Jun 16th, 2007, 02:07 PM
What is the namespace I need for this? Also it's for a window application form.


By the way, its been a while since i've seen you here.

Jennifer.

penagate
Jun 16th, 2007, 02:11 PM
Oh. The Session array is a member of the Page object (or class--can't remember which). I assumed you were talking about an ASP.NET application.

For a desktop app, you can just make a public static property of any class. I do this in PHP too, rather than using global variables. This allows you to organise application settings logically.

JenniferBabe
Jun 16th, 2007, 02:23 PM
ok thanks.