Use of Session in ASP.NET
Session
Session State information is available to all the pages opened by a user, during a single visit.
Step 1: Create a Master Page First, like the following image.

Step 2: Create a Login page using the Master page.

Write a code to create the Session
protected void LoginButton_Click(object sender, EventArgs e)
{
if (LoginUser.UserName == "deepak" && LoginUser.Password == "123")
{
//here I am creating a session and store login name to session user
Session["user"] = LoginUser.UserName;
Response.Redirect("Default.aspx");
}
}
Now, what I want to do is, when the user clicks on the login button, the condition should be executed after the condition returns true login name is stored in session, and the page gets redirected to the home page and on the top of the home page the Login name will display like the following:
welcome Deepak Logout
And Linkbutton text will change the Login to Logout such as the following image

To achieve this, write the following code in the master page page_load event:
protected void Page_Load(object sender, EventArgs e)
{

Deepak RatanPosted Mar 20, 2015, 3:15 AM
protected void Page_Load(object sender, EventArgs e){ if (Session["user"] != null) { Label1.Text = Session["user"].ToString(); LinkButton1.Text = "Logout"; } } ""IN THIS LABEL1.TEXT IS NOT WORKING IN MASTER PAGE"" WHAT WILL BE THE SOLUTION FOR THIS
Hussain AhmedPosted Mar 12, 2014, 10:55 AM
Good
amarnath reddy ambatiPosted Mar 8, 2014, 1:02 AM
Good Example Thank you...