Sunday, January 24, 2010

Cookies in ASP.Net

Cookies are the things used to store users’ information. For example if we want to keep a track of userIds of the visitors who have visited any site so we can get it through cookies. We can store these all things in cookies from where we can retrieve it back. Let’s take a very simple example... When you login into your any account they ask you as “Remember password” etc… What is this? It’s nothing but cookies. They store your information in cookies of course in encrypted format so that no one can edit it. Using these cookies they can retrieve your password again and again based on your userId or username. Cookies are dependent on websites and not on any particular page. Cookies are exchanged between browser and server.

Most browsers support cookies of up to 4096 bytes. Browsers also 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.

Cookies are created by browsers and they store the cookies sent by websites. If user doesn’t want to store the cookie, user can disable cookies. Once user disables cookies, cookies won’t get stored even if website sends it to the browsers. Way to delete all the Cookies is: - Open Internet Explorer and select the menu "Tools > Internet Options", Press the button "Delete Cookies". This will delete all cookie files from your computer.

Later we will check how to write and read a cookie..

No comments:

Post a Comment