Cookie is the small file which is created on the client's system and has information about clients. It is usually used for state management and are stored in a
client system and use it when needed.
It's necessary to know how to use it when the website need to send the data.
http://msdn.microsoft.com/en-us/library/ms178194.aspx
http://msdn.microsoft.com/en-us/library/system.web.httpcookie.aspx
http://www.codeproject.com/Articles/31914/Beginner-s-Guide-To-ASP-NET-Cookies
-----------------------------------------------------------------------------------
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ColourCookie : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
HttpCookie cookieColour = new HttpCookie("prefColour");
cookieColour.Value = lbxColours.SelectedItem.ToString();
cookieColour.Expires = (DateTime.Now.AddHours(1));
Response.SetCookie(cookieColour);
Response.Cookies["VisitorData"]["FirstName"] = "John";
Response.Cookies["VisitorData"]["FirstName"] = DateTime.Now.ToString();
}
}
-----------------------------------------------------------------------------------
No comments:
Post a Comment