The Session
property provides programmatic access to the properties and methods of the
System.Web.SessionState.HttpSessionState
class.
Because ASP.NET pages contain a
default reference to the
System.Web namespace (which contains the
HttpContext
class),
you can reference the members of HttpContext on an .aspx page
without using the fully qualified class reference to HttpContext.
For example, you can use
Session["SessionVariable1"] to get or set the value of the session state variable
so, you just use session as below,...
// to set session variable write statement as below,
Session["UserId"] = 1;
Here, "
UserId
" is name of your session variable which is set to value
1 in above line. no
declaration like integer,string etc...
To fetch value of session variable...
int UserId = Session["UserId"] ;
Happy Coding!
:)