Dear All, I just wanted to know how to tamper cookie(just for knowledge purpose :-)).I have created one application and tried to tamper the cookie but its not working. Code:
protected void Button1_Click(object sender, EventArgs e) { if (Request.Cookies["myCookie"] != null) { Response.Redirect("Default2.aspx");
}
else
{
HttpCookie storeData = new HttpCookie("myCookie");
storeData["name"] = "Arin";
storeData["color"] = "Blue";
storeData.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(storeData);
Response.Redirect("Default2.aspx");
}
}
Code(Default2.aspx): protected void Page_Load(object sender, EventArgs e) {
HttpCookie storeData = Request.Cookies["myCookie"];
string myString= storeData["name"];
TextBox1.Text = myString;
}
Saved Cookie Contents: myCookie name=Arin&color=Blue localhost/ 1024 1178851840 29993085 467738336 29992884 *
When I run the code its crateing the cookie,also next time its checking if the cookie exists,if yes then its redirecting to default2.aspx page and i am getting name in the text box. But when I am tampering the cookie Lets say when I am changing Arin to Arinzzz, its not getting reflected,the Application is considering no cookie name "myCookie " exsists and is crateing a new cookie and thus I am not getting Arinzzz in Default2.aspx,am I missing Something.Thanks in advance for ur help.