I am trying to store userid in session but failed to do so. Please view the code below:
String query = "select count (*) from USERINFO where USERID='" + textuserid.ToString() + "' and USERNAME='" + textusername.Text + "' and MVerifyPass='" + textpassword.Text + "'";
SqlCommand cmd = new SqlCommand(query, con);
String output = cmd.ExecuteScalar().ToString();
if (output == "1")
{
Session["userid"] = textuserid;
Session["User"] = textusername.Text;
Response.Redirect("~/app/Dashboard.aspx");
}
else
{
Response.Write("Your User ID and Password is wrong!");
}
How can I store the userid in the session and convert the varchar
into int
?
Any help will be highly appreciated.