Tuesday, May 5, 2009

Where does cookies are stored in local Hard drive ?



This is one of the interesting things to find out the cookies in your local drive. First of all, From "Explorer Folder Option ", Select, show hidden files and folder.


Fig 1.2 : Show Hidden files and Folder Settings


Now Browse into document & settings of the current user and open the cookies folder. Now looks the picture.

Fig 1.3 : Reading Cooking info in local System

Friday, May 1, 2009

How to Read data from cookies ?

Now , its times to retrieve data from cookies. Ok, before reading cookies, first of all we need to check whether a cookies was found or not. "Its always good practice to check cookie before read it, because is browser is disable cookies.



How to create cookies ?

For working with cookies we need to use namespace System.web














Now , have a look, on the code , that how can we create a cookies and add it with web response .3










The cookies which has been created will persist , until browser has been closed. we can persist the cookies. But how? Just after few point I have discussed it.

Advantages & Disadvantages of of Cookies

Advantages
Following are main advantages of using cookies in web application:
  • It's very simple to use and implement.
  • Browser's taking care send data.
  • For multiple sites cookies, Browser automatically arranges them.
Main disadvantages of cookies are:
  • Its store data in a simple text format. so it's not secure at all.
  • There is a size limit of cookies data ( 4096 bytes / 4KB).
  • Number if cookies also limited. Most Browser provides limits of storing cookies is 20. If new cookies came, it will discard the old one. Some of browser support up to 300.
  • We need to configure browser. It will not work on a high security configuration of browser. [I have explained about this in details.]

How Cookies are started ?



When client request to the server, server send the cookies into client . The same cookies can be referred for subsequent request. As for example, if codeproject.com stores session id as a cookies, when any client hits first times on the server, server generates the session id and send it as a cookies to client. [As given in Fig 1.0]




Fig 1.0 : Initial state of cookie creation






Now for all other subsequent from the same client it uses the session-id from cookies, just like the picture below:




Fig 1.1 : Subsequent request for other pages

Browser and web server are responsible for exchange cookies information. For different sites, browser keeps cookies differently. If any pages need information from cookies, when that URL is being hit, first its search for local system for cookies information then its moved to server with that information.




What are Cookies ?

Cookies are the small files that are created on the client's system or client browser memory (if temporary). Its use for State management that I have already discuss on my view state article. So we can store small piece of information in a client system and we can use it when we needed. Most interesting thing is that Its works transparently with the user. It can be easily used any where of you web application. Cookies store information in a plain text format. If any web application using cookies, Server send cookies and client browser will store it. The browser then returns the cookie to the server at the next time the page is requested. The most common example of using a cookie is to store User information, User preferences , Password Remember Option etc. Cookies has many advantages and disadvantages. I will comes to this points , but first have a look how cookies are started.
Heaven - it is ok but try to earn money at hellishdollars.com !