Session
how to use session? with example practically please help me.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Mar 5, 2012, 2:08 AM EST
Sessions can be used to store even complex data for the user just like cookies. Actually, sessions will use cookies to store the data, unless you explicitly tell it not to. Sessions can be used easily in ASP.NET with the Session object.
Ex:-
<%@ Page Language="C#" %>
<%@ Page Language="C#" %>
Thanks
If this post helps you mark it as answer
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 5, 2012, 2:11 AM EST
to store in session variable use,
Session["LastName"] = "Trivedi"; to retrive string lastname = convert.tostring(Session["LastName"]) hope this help. please refer http://msdn.microsoft.com/en-us/library/ms972429.aspx this articel has initial information about session. hope this help.SenthilkumarRank #387 · 6.5K reputationPosted Mar 13, 2012, 9:59 PM EDT
Session["Key"] = value;
The session is the key word and it has the two parts. Key and Value. The value can be assigned and accessed using the session key. The value will be stored as object. It has to be type casted.
Session["UserDataSet"] = dsUsers;
when you retrieve and assign back to the dataset then
DataSet dsUsersData = (DataSet) Session["UserDataSet"];
The session mode can be set to the application level or machine level.
The configuration file allows you to set the mode of session saving.
The SessionState configuration tag is available in the web.config.
The Session state can be InProc, StateServer, SqlServer.
when you say InProc then it will be stored in the processor memory. Typically you can say it will be stored on asp.net_wp.exe.
The stateserver will be stored on the memory but it can be remote and multiple application can share same.
The sqlserver state mode will maintain the state of the session. The framework has the scripts which allows you to set up this mode.