Hi, The browser stores the message which is given to a web browser by web server into a text file. The message is then sent back to the server if only the browser requests a page from the server each time.
a cookies are A very small text file placed on your
hard drive by a Web Page server. It is essentially your identification
card, and cannot be executed as code or deliver viruses. It is uniquely
yours and can only be read by the server that gave it to you
cookies purpose is To tell the server that you returned to that Web page
it may help you by saving your time
If you personalize pages, or register for products or services, a cookie helps Microsoft remember who you are.
Next time you return, we know to show you the information you
requested. Or, when you register for another product or service, all
you need to do is type in your e-mail address and a password. We then
fill in any questions you've already answered. Of course, if you never
register or leave personal information with Microsoft, then the server
only knows that someone with your cookie has returned to the Web site.
You are in charge of deciding whether we know anything about you. But
the more you tell us about yourself, the more we can help you find
information or products you want
how to use it
in order to handle a cookie in your system you should aware of 2 thing:
1-how to create them
2- how to delete them
so,first in order to create a cookie you have 2 variable must be defined as they are the cookie name and the duration of the cookie before it expired
in order to create a cookie it looks like this one
Cookies are associated with a Web site, not with a specific page, so the browser and server will exchange cookie information no matter what page the user requests from your site. As the user visits different sites, each site might send a cookie to the user's browser; the browser stores all the cookies separately.
Cookie Limitations
Most browsers support cookies of up to 4096 bytes. THerefore, cookies are best used to store small amounts of data, or even better,only an identifier such as a user ID. This user ID can then be used to identify the user and read user information from a database or other data store. In the case of Forms Authentication, the Forms cookie can store its own expiration time, as well as custom UserData (roles, preferences, etc.) This can eliminate the need to use Session to store small amounts of user-specific data. Forms auth cookies are normally encrypted. Cookie data can be compressed to allow storage of entire classes in .Net.
Browsers impose limitations on how many cookies your site can store on the user's computer. Most browsers allow only 20 cookies per site; if you try to store more, the oldest cookies are discarded. Some browsers also put an absolute limit, usually 300, on the number of cookies they will accept from all sites combined.
A cookie limitation that you might encounter is that users can set their browser to refuse cookies. If you define a P3P privacy policy and place it in the root of your Web site, more browsers will accept cookies from your site. Instead of creating and uploading privacy policies to your sites, you can also serve a "compact policy," i.e. a "p3p" HTTP header, e.g.: "IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT". A policy generator can produce one instead of an XML file. In ASP.NET it's a one-liner that you can put into your page base class or master page:
HttpContext.Current.Response.AddHeader ("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
If you do so programmatically, just make sure to add this line early in the page life cycle. If your code redirects or throws an exception too early, the "p3p" header will be missing. As an alternative, you can get IIS to send this header at all times, but in this case the header will appear on everything: images, stylesheets, JavaScript files, etc. Those files don't really need it.
You can review the official P3P Policy specification here: http://www.w3.org/P3P/usep3p.html Although cookies can be very useful in your application, you should try to avoid having the application depend on being able to store cookies. Do not use cookies to support critical features. If your application must rely on cookies, you can test to see whether the browser will accept cookies. ASP.NET Session relies on cookies. With ASP.NET, we have the ability to configure the Session as "cookieless" where the SessionId is "munged" onto the URL. You can also set this to "auto" and the runtime will determine which mode to use.
Check out the following article.
1.http://www.codeproject.com/KB/aspnet/cookies_in_c_.aspx
2.http://msdn.microsoft.com/en-us/library/aa289495(VS.71).aspx
carle laiPosted Sep 23, 2009, 10:52 PM
venkat mohanPosted Sep 14, 2009, 3:04 PM
a cookies are A very small text file placed on your hard drive by a Web Page server. It is essentially your identification card, and cannot be executed as code or deliver viruses. It is uniquely yours and can only be read by the server that gave it to you
cookies purpose is To tell the server that you returned to that Web page
it may help you by saving your time
If you personalize pages, or register for products or services, a cookie helps Microsoft remember who you are.
Next time you return, we know to show you the information you requested. Or, when you register for another product or service, all you need to do is type in your e-mail address and a password. We then fill in any questions you've already answered. Of course, if you never register or leave personal information with Microsoft, then the server only knows that someone with your cookie has returned to the Web site. You are in charge of deciding whether we know anything about you. But the more you tell us about yourself, the more we can help you find information or products you want
how to use it
in order to handle a cookie in your system you should aware of 2 thing:
1-how to create them
2- how to delete them
so,first in order to create a cookie you have 2 variable must be defined as they are the cookie name and the duration of the cookie before it expired
////////////SET THE COOKIE//////////////
Response.Cookies["test"].Value = UserName.Text ;
Response.Cookies["test"].Expires = DateTime.Now.AddYears(30);
where test is the cookie name
and the username.text is the textbox that will be used to define the cookies information
Response.Cookies["test"].Expires = DateTime.Now.AddYears(-30);
/////////check to see if cookie presented//////////
if (Request.Cookies["test"] == null)
TextBox2.Text = "No cookie found";
else
TextBox2 .Text = Request.Cookies["test"].Value;
if helpful please mark "Do you like answer"
thank you
Niradhip ChakrabortyPosted Sep 14, 2009, 1:28 AM
Cookie Limitations
Most browsers support cookies of up to 4096 bytes. THerefore, cookies are best used to store small amounts of data, or even better,only an identifier such as a user ID. This user ID can then be used to identify the user and read user information from a database or other data store. In the case of Forms Authentication, the Forms cookie can store its own expiration time, as well as custom UserData (roles, preferences, etc.) This can eliminate the need to use Session to store small amounts of user-specific data. Forms auth cookies are normally encrypted. Cookie data can be compressed to allow storage of entire classes in .Net.
Browsers impose limitations on how many cookies your site can store on the user's computer. Most browsers allow only 20 cookies per site; if you try to store more, the oldest cookies are discarded. Some browsers also put an absolute limit, usually 300, on the number of cookies they will accept from all sites combined.
A cookie limitation that you might encounter is that users can set their browser to refuse cookies. If you define a P3P privacy policy and place it in the root of your Web site, more browsers will accept cookies from your site. Instead of creating and uploading privacy policies to your sites, you can also serve a "compact policy," i.e. a "p3p" HTTP header, e.g.: "IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT". A policy generator can produce one instead of an XML file. In ASP.NET it's a one-liner that you can put into your page base class or master page:
HttpContext.Current.Response.AddHeader ("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
If you do so programmatically, just make sure to add this line early in the page life cycle. If your code redirects or throws an exception too early, the "p3p" header will be missing. As an alternative, you can get IIS to send this header at all times, but in this case the header will appear on everything: images, stylesheets, JavaScript files, etc. Those files don't really need it.
You can review the official P3P Policy specification here: http://www.w3.org/P3P/usep3p.html
Although cookies can be very useful in your application, you should try to avoid having the application depend on being able to store cookies. Do not use cookies to support critical features. If your application must rely on cookies, you can test to see whether the browser will accept cookies. ASP.NET Session relies on cookies. With ASP.NET, we have the ability to configure the Session as "cookieless" where the SessionId is "munged" onto the URL. You can also set this to "auto" and the runtime will determine which mode to use.
Check out the following article.
1.http://www.codeproject.com/KB/aspnet/cookies_in_c_.aspx
2.http://msdn.microsoft.com/en-us/library/aa289495(VS.71).aspx