Rating: 4.0/5. From 1 vote.
Please wait...

Introduction to Cookie Files

First of all, we will go into the following questions: what are cookies, how they work, how they’re saved on the hard disk, and how to change their configurations. It will be easy for you to understand test cases for cookie testing if you have a straight answer to these questions.

So, cookies are specific information that is saved on the user’s hard disk in the text document of a particular webserver. This data is used by web browsers in order to get information from this local device.

As a rule, all the cookie files have the user’s personal data or information that is used for data exchange among different web pages.

Why Do We Use Cookies?

Cookie files can be considered as identification of the user in order to track his/her actions on the web portal pages.

For example, if you use http://www.example.com/1.html domain, then web browser prompt will for example.com web server for the 1.html page. Next time if you go to http://www.example.com/2.html, a new request will be sent to example.com webserver to send the 2.html page, and web server won’t know who used the previous 1.html page.

But what to do, if a client needs information about the previous session with the webserver? In this case, we need cookie files. They are some kind of connector between a user and a web server.

How Do Cookie Files Function?

The HTTP protocol is used for information files exchange and cookie file support.

There are two types of HTTP protocols:

  • Stateless HTTP;
  • Stateful HTTP.

The first one doesn’t store any information about browsing history. On the contrary, the second one saves some data about previous processes between the web browser and web server. And cookie files use this protocol to keep contact with a client.

Every time when a user visits the web site or the page that uses cookie, small code inside this HTML page (usually it’s a call to some language scripts to write the cookie such as JAVAScript, PHP) writes a text file on user’s computer named a cookie.

Here is an example of a program code that is used for writing the cookies: Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME. It can be placed on any HTML page and prove useful to many quality assurance companies.

If the user visits a similar page or domain later, this cookie is read from disk and used to identify the second visit of the same user on this domain. The expiration time is set while writing the cookie file and decided by the application that will use the cookie file.

Usually, two types of cookie files are written on the local user’s PC:

  • Session Cookies: the file is active until the browser called cookie is open. When you close the browser, these cookie sessions are deleted permanently.
  • Persistent Cookies: the files are kept on the PC permanently and last for months or years.
Types of cookies

Types of cookies

How and where are cookies stored?

When any web application makes a cookie file, its information is stored on a hard disk of a local machine. The path where one can find such a file depends on a browser first of all. Different browsers store the cookie on different paths.

Here are some examples:

Internet Explorer: “C:\Users\username\AppData\Roaming\Microsoft\Windows\Cookies”.
Windows 8 и Windows 10: “C:\Users\username\AppData\Local\Microsoft\Windows\INetCookies”.

The “Users” locale can be changed to any user account that has administrator rights. Moreover, you can easily find a path to cookie files, if you use technical settings of the used browser.

In such a browser as Mozilla Firefox, you can see the cookies in the browser settings. For this, you just need to click on the Open menu > Web Developer.

In Google Chrome you can find cookie files entering chrome://settings/content/ Cookies in the address bar. Or it is possible to get access to cookie files through browser console (F12 > application > storage > cookies >).

How Are Cookie Files Stored?

Let’s take a look at the example of a cookie file written by rediff.com in Mozilla Firefox. When you open the rediff.com page in this browser or log in to your Rediffmail account, a cookie file is written on the hard disk.

To view this object, you have to click on the Show cookies button, and then go to Rediff.com with this list of cookie files.
In this list, you can find those cookies by Rediff with different names.

For example:

Site: Rediff.com Cookie name: RMID
Name: RMID (Name of the cookie)
Content: 1d11c8ec44bf49e0… (Encrypted content)
Domain: .rediff.com
Path: / (Any path after the domain name)
Send For: Any type of connection
Expires: Thursday, December 31, 2020, 11:59:59 PM

Applications Where Cookie Files Can Be Used

  1. Online store with shopping cart. Cookie files are used to maintain the online ordering system.
  2. Public information website: cookie files will help the user to choose what pages he/she wants to visit or not (user setup is saved in the cookie file, and when the user is online, he/she won’t see those pages).
  3. User tracking. This parameter is useful for the analytical process of any website (for example, the website owner can see the number of unique visitors per day and so on).
  4. User sessions: Cookies can track user sessions with certain domains using user ID and password.

Test Cases for Web Application Cookie Testing

The first obvious test case is to check if your application is writing cookies correctly on a disk. Also, you can use Cookie Tester application if you don’t have a special web application for testing but you must understand the cookie concept for testing.

Here are some examples of web application cookie testing:

  1. As the privacy policy of cookie files make sure that your documents don’t contain your personal data in the cookie.
  2. If you don’t have another choice but to save personal data in cookie files, make sure that this information is encrypted.
  3. Make sure that the site that you test doesn’t use too many cookie files. It will annoy users if the browser often prompts for cookies. Whereas, it can cause the loss of site traffic and the business eventually.
  4. Deactivate cookie files in the browser settings. If you use cookie files on your site, the main functionality of your sites won’t work if you deactivate cookies. Then try to go to the tested site.
  5. Accept/reject some cookie files. The best way to test website performance is to reject all the cookies. If you write 10 cookie files in your application, you accept some cookies randomly. Try to accept 5 files and reject 5.
    To execute this test, you can set the browser parameters to prompt whenever the cookies are written to disk. In this prompt window, you can accept or reject the cookie file. Try to get access to the main website functional and see if pages are crashed or data is corrupted.
  6. Delete cookies. Allow the site to write the cookies and then close all the browsers and manually delete all the cookies for the site under test. Go to webpages and check their behavior.
Process of testing the cookies

Process of testing the cookies

Conclusion

We described all the main aspects of cookies using in the web development sphere. Also, we analyzed exhaustive test cases to check quickly and easily the functionality of cookies when you develop a particular program code.

Leave A Comment