Declare :
Session[“userId”]=”1”;
Retrive:
string userId =(string)Session[“userId”];
Interviews3 answers
What is session? How do you initialize a session and how you declare it?
3 Answers
Bidyasagar MishraPosted Jul 23, 2019, 7:52 PM EDT
Session Declaration is all follow
{
Session[“UserName”]=”Vaibhav”;
}
Use declared session like
{
string Name =(string)Session[“UserName”];
}
Vaibhav SurvePosted Jul 17, 2019, 8:44 PM EDT
Session is a cookie variable in server and it is handle in server level in our entire web technologies (asp.net,asp.net mvc).
- in asp.net
System.web.HttpContext httpcontext= new System.web.HttpContext();httpcontext.Current.Requiest.Session["variable_name"]="variable_value";
- in Asp.net MVC
I hope above is ok our understanding purpose.Session["variable_name"]="Session value";
Santosh Kumar RangumudriPosted Jul 1, 2019, 4:17 AM EDT



