Session : session is Server Side saving your data for the
session you are using the site, in the memory and that is defined in web.config for session state
section otherwise 20 mins by default.
Advantages:
How to fetch the record from session like:
Advantages:
- It easy implement and we can store any kind of object.
- It helps handle user state and data all over the application.
- Stores client data separately.
- Session is secure and transparent from the user.
Disadvantages:
- Performance overhead in case of large volumes of data/user, because session data is stored in server memory.
Who to create session like :
protected void
btnok_Click(object sender, EventArgs e)
{
Session["FirstName"]
= txtfName.Text;
Session["LastAge"]
= txtLast.Text;
Response.Redirect("Default2.aspx");
}
The session state is used to maintain the session of each user throughout the
application. Session allows information to be stored in one page and access in
another page and support any type of object. they will show username in all
the pages for that they will store username in session and they will access
that session username in all the pages.
How to fetch the record from session like:
if(!IsPostBack)
{
//if session is null then manual provide session value
if (Session["FirstName"] == null && Session["LastName"] ==null)
{
Session["FirstName"]
= "Bhavesh";
Session["LastName"]
= " Thumar";
lblMsg.Text = "Welcome
" + Session["FirstName"]
+ Session["LastName"];
}
else
{
//to print session value
lblString.Text = Session["FirstName"]+"
" + Session["LastName"];
lblfName.Text = Session["FirstName"].ToString();
lbllName.Text = Session["LastName"].ToString();
}
}
It is an amazing post. Very useful to me. I liked it .Take a look to my blog iOS Training in Chennai
ReplyDelete