Cookies Testing : Essential for Web Application


This article will deal with Cookies and their use. On hearing the name Cookies, the mouth automatically fills with water, and we start to imagine different flavors of them. But here we are not talking about any food thing. The meaning of Cookies here is some technical smoke. Now everyone must have some idea of what cookies are. But I would like to discuss a little bit about cookies just for the sake of introduction so that everyone gets an idea about cookies.

Cookies?

Cookies are also known as Browser cookies or tracking cookies. A Cookie is an information which a web site put on the hard disk and is saved so that it can be used in the future. A Cookie is a way to record the preferences of a user.

It is a kind of process of storing information about the user by the server and that too is in the user's end. It depends on the browser that where they will store the cookies. 

These Cookies are stored without taking any permission from the user. The place where they are stored is called the Cookie list. Whenever the user wants the same page to be displayed, the web browser uses the related Cookie and sends it to the web server.

This process as well takes place without giving any notification to users. Some browsers store them as a different file separated from each other while some store all the cookies in a single cookie.txt file. Opera stores all the cookies in a single cookies.dat file. Cookies are nothing but an encrypted text file, very small in size.


Types of Cookies

There are two types of Cookies.

  1. Session Cookies
  2. Persistent Cookies.

Session cookies are active when the browser is opened and are deleted on closing the browser; they are also known as per session cookie while Persistent cookies are written permanently on the user machine and lasts for months or years, these cookies are provided with an expiration date with them.

As time moves on these cookies get deleted on the completion of their time period. These cookies are created when we request our browser to load any website. That particular website sends an information to the browser which motivates that browser to create a text file.

The browser sends the created text file to the website every time the user wants to go to the same website for which the cookie is created. It depends on the web sites how they store information in the user's system.

Generally it is a pair of name and value which is later used by the web sites to load the page faster.

These Cookies are maintained by the HTTP protocol. There are two types of HTTP protocol: Stateless and Stateful. Stateful protocol is used to maintain cookies as this type stores information about the sites a user a visited. It keeps a sort of history of those websites.

Applications of Cookies

Cookies are used by some sites to store information about their visitors. This is further used to send offers related to the services they use before on that site. to those visitors.

web site Tracking : Using information written in cookies, one can get information about the sites visited by the users.

Shopping : Cookies help users to do intellignet shopping. They keep information regarding products the user is interested in and the next time the user opens his browser, these cookies help in reminding him about the products last time he visited.

Advertising : Cookies are used in advertising any brand, product or site. Their job is to rotate the ad sequence so that users don't have to face the same product ads again and again. It also help web sites to know about user's area of interest. The web sites uses information stored in cookies according to which it helps in sending related links to that user.

Are Cookies harmful for Users?

No, Not at all. Cookies are not a harm for our system. There is a myth about cookies in people's mind that cookies stay in our system and collect all the personal information about users including records about the sites we surf. Thus it can be a question in everyone's mind that if they can do harm to us or not. But its not true.

Cookies do not gather any personal information from our system. They just allow web sites to store information on a user's machine so that it can be retrieved later. They are not modules or pieces of code; that is why they are not able to execute themselves. Neither they have the capability to make a copy of themself.

Thus, Cookies are not viruses. They do not contain any virus in any way. They are just to enhance the speed of loading websites and in that way help in making browser's job faster. Although they can be used by someone to check the record about the web sites you surf usually.

What if I want to remove Cookies?

Cookies can be removed from the folder in which the browser has created them. The following are the steps showing how can we delete any cookie file from the system:

  • Click on Windows Explorer.
  • Go to Tool bar, select the search button from there.
  • Type 'cookie' in the space provided for 'Folders and Files'.
  • This should be searched under 'My Computer'. Give this specification in space for 'Look In' option.
  • Hit the key for 'search Now'.
  • Now select and open the folders that are retrieved.
  • And from there select any cookie file you want to delete. Click on the 'Delete Key' to delete that file.





How can we do Testing for Cookies?

Testing Cookies is really a necessity because there are so many web sites which has lots of relevant information.

1. Make sure that there are no personal data is stored in the cookies. Check also if it has any sensitive content or not.
If the data is so important that you can't do anything except storing it then try to store it in encrypted form.

2. Remove all the previous cookies from your system. Then, Disable cookies by going in the browser settings. On disabling these cookies, the sites will stop their functionality. This would be the case if we are using cookies on our sites. In your test session, try to access the web sites. Then notice if the message related to notifications regarding use of Cookies are being displayed on the screen or not.

How can we disable Cookies for our system?

  • For Opera users, it can be done by clicking on 'File' menu. Then 'Preferences' and finally selecting 'Privacy'. Similarly, if you use Mozilla Firefox,
  • Deleting Cookies can be done by Clicking the 'Tools' menu, Then select 'Options', The next step is to click 'Privacy' button and under cookies Click the Cookies' button. This is the method to delete cookies from hard disk drive. If you want to disable the cookies, You should follow the steps below:
  • Click the 'Tools' menu, then 'options', select 'Privacy' button and go to 'Cookies'. There you find an option listed as 'Allow sites to set Cookies'.
  • To disable cookies you just have to uncheck the option.
  • Similarly, we can disable the cookies for other browsers as well. The method would be different otherwise.
    No page should be crashed while you disabling the cookies.

3. Edit Cookies Manually : This is also known as corrupting cookies. We just have to edit the cookie in notepad simply by changing some parameters. After doing this we should check websites. Because sometimes they allow to read the data inside it for any other domain. This should not be happen in your case.

                                                                You can edit Cookies in notepad

4. Test cookies on Multiple Browsers:
Now another test which is really very important. Open other browsers to Check whether they are writing cookies or not. This can be done manually.
Another way is to delete cookies. How will we do that? This has explained on top of the tips although but let me remind it once more. First let the sites to write cookies then close all the browsers and then delete all the cookies. And after that open the web pages to test the differences.

5. Another way to check the functionality of web sites is to accept some of the cookies and reject some of them. Suppose there are 7 cookies available; then accept only a few of them say 4 and reject the remaining 3 of them. Check also whether the pages are crashing or working properly.

6. Do test for application as well which deals with the authentication of login information. We can do it by changing the username parameters in the address bar. This is just to see the behavior of the application.

Drawbacks of Cookies:

Loss of Site Traffic- The site which has cookies is not able to perform any operation. It gets completely disabled. This resulted into Site Traffic Loss.

Hard drive Space- As we know that these cookies are stored into the hard disk of the system, and fill the space of our system's hard drive. So its better to delete those cookies which do not mean to you.

Although they are really very small chunks of text like 4k or a bit more, hardly about 250 to 300 cookies can be stored, if more cookies would be there waiting to get stored throw the very previously stored cookie in hard drive.

Cookies take up valuable hard drive space, so it may be to your advantage to delete a few on occasion, especially third-party cookies. Third-party cookies are placed on your computer by sites you haven't visited. They usually come from companies who place ads on sites you have visited. Luckily, most browsers give you the option of rejecting only third-party cookies.

Other cookie based threats - Here we are talking about a case in which a browser is connecting to the server by using an unencrypted network and that can be a non-secured Wi-fi channel. But it happens very rare.

It can be assumed that if any cookie is used very frequently between a browser and website, cookie's information can be taken by any unauthorized person if he would be able to share data transmission. Using a good antivirus on your system can solve this problem to a very large extent.

Conclusion : Cookies are not a code or part of any code, it is just an encrypted text file. Unlike Viruses, It do not harm our system. These are nothing but a string of text which is generated by Web servers and Web host sites.

Besides this, some restrictions are also applied on cookies protocol recently so that we can make more control over it. Cookie testing is really a very important part of web application. It helps in maintaining stability of any application.

Resources

Microsoft Application Center Test
Important Points to Remember Web Testing
Testing.NET applications
Load Testing of Web Applications Using Visual Studio Team System 2008