- Create 2 Web form pages named: Login , named: Secondpage
- Now create two text boxes and one Login button
- on Button click event of Login page add this code:
- if (TextBox1.Text == "abc" && TextBox2.Text == "abc")
{
Session["login"] = TextBox1.Text;
Session["password"] = TextBox2.Text;
Response.Redirect("Secondpage.aspx");// redirect page to Secondpage.aspx - Now on Secondpage Page_Load event add below code
- if (Session["Login"] != null && Session["password"]!=null)
{
Response.Write(Session["login"].ToString());
Response.Write(Session["password"].ToString());
}
else
{
Response.Write("Session has expired");
} - To expire session add below code into Web.config. Session will be expired after 1 minute
- <sessionState mode="InProc" cookieless="false" timeout="1" />
Sunday, March 1, 2015
Create Session on Login page using C# and redirect it to next page also expire session
Labels:
.net,
C#,
create,
expire,
expire session,
login page,
page,
redirect,
Session
Subscribe to:
Comments (Atom)