how to declare session variable in global.asax file

  • Thread starter Thread starter khawar
  • Start date Start date
K

khawar

please provide code sample, i was having trouble declaring
interger and string variable and can we also initialize
them at the same time
thanks for help
 
Hi khauar, I provide you with a sample that store and
require variables in a Session object.

To save the variables...

string s = "String Value";
int i = 23; // My lucky number;

Session[ "stringValue" ] = s;
Session[ "intValue" ] = i;
....

To get the values...

string s2 = ( string ) Session[ "stringValue" ];
int i2 = ( int ) Session[ "intValue" ];

Regards
Gaston Quirque
Microsoft MVP
 
Back
Top