You need to change your code.
Please use the following code.Hope it will work.If doesn't fulfill your requirement, please fell free to leave your comment.
try
{
if (!String.IsNullOrEmpty(TextBox1.Text) && !String.IsNullOrEmpty(TextBox2.Text))
{
if (CheckBox1.Checked)
{
if (Request.Cookies["login"] != null)
{
HttpCookie getCookie = Request.Cookies.Get("login");
Response.Redirect("Default2.aspx?UserName : '" + getCookie.Values["UserName"].ToString() + "' & Password : '" + getCookie.Values["Password"].ToString() + "'");
}
else
{
HttpCookie cookie = new HttpCookie("login");
Response.Cookies.Add(cookie);
cookie.Values.Add("UserName", TextBox1.Text.ToString());
cookie.Values.Add("Password", TextBox2.Text.ToString());
cookie.Expires = DateTime.Now.AddHours(2);
}
}
else
{
HttpContext.Current.Response.Cookies.Remove("login");
Response.Cookies["login"].Expires = DateTime.Now;
}
}
}
catch (Exception ex)
{
ex.ToString();
}
If this would be really helpful to you then don't forgot to Vote and Make Answer as Accepted.