Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Anyone Explain & give C# coding for session validation...




have to find new user or current user using user_session id...
Posted
Updated 5-Dec-11 19:21pm
v2

Please tell us you required to which type of validation?
 
Share this answer
 
Comments
M.Narmatha 6-Dec-11 1:20am    
have to find new user or current user using user_session id...
C#
Session["username"] = txtUsername.Text;

if(Session["username"] == null)
{
   //Redirect to login page.
}
else
{
   //Redirect to home page
}


Regards,
-Eduard
 
Share this answer
 
v2
here is some example hope it helps you to understand session

C#
protected void btnImage_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            adp = new SqlDataAdapter("Select UserName from AdminLogin where UserName='" + txtusername.Text + "' and Password='" + txtpassword.Text + "'", conn);
            tbl = new DataTable();
            adp.Fill(tbl);
            if (tbl.Rows.Count == 0)
            {
                cls.MsgBox("Invalid UserName or Password...Login Failed", this.Page);
                txtpassword.Focus();
                return;
            }
            Session["User"] = tbl.Rows[0]["UserName"].ToString();
            Session["SessionId"] = "valid";
            Server.Transfer("Default.aspx");
        }
        catch (Exception ex)
        {
            cls.MsgBox(ex.Message, this.Page);
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900