string s = ConfigurationManager.ConnectionStrings["RegistrationConnectionString2"].ConnectionString; protected void LoginButton_Click1(object sender, EventArgs e) { if (Page.IsValid) { using (SqlConnection con = new SqlConnection(s)) { SqlCommand cmd = new SqlCommand("spUserlogin", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@username", TextBoxUsername.Text); cmd.Parameters.AddWithValue("@password", TextBoxPassword.Text); SqlCommand cmd1 = new SqlCommand("spAdminlogin"); cmd1.CommandType = CommandType.StoredProcedure; try { con.Open(); int value = (int)cmd.ExecuteScalar(); if (value == 1) { if (CheckBox1.Checked) { HttpCookie user = new HttpCookie("user_cookies"); //creating cookie object where user_cookies is cookie name user["New"] = TextBoxUsername.Text; //cookie content user.Expires = DateTime.Now.AddYears(3); // give the time/duration of cookie Response.Cookies.Add(user); // it gives the response in browser } else { Session["New"] = TextBoxUsername.Text; } Response.Redirect("home.aspx"); } else { Label_Login.Visible = true; Label_Login.Text = "Use Correct username and password"; } } catch (Exception ex) { labelError.Visible = true; labelError.Text = "Something went wrong! Contact your devloper " + ex.Message; } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)