How can I insert values in Session Variables ?

Here is the code for inserting values in session:-

Session["LoginId"] = txtLogin.text;
Session["Username"] = txtUser.text;

Here Session["LoginId"] is Session Variable and txtLogin is Textbox which used for inserting values in Session Variable.

for retrieving values from session use:-

string Login_id = Session["LoginId"].ToString();
string User_Name = Session["Username"].ToString();

Here Login_id is a string variable which holds value of LoginId Session variable value.

No comments:

Post a Comment