Website Cookie Testing & Test Cases for Testing Web Application Cookies

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated February 28, 2024

Introduction to Cookies

Primarily we will focus on what exactly HTTP cookies or Internet cookies are and how they work.

It would be easy for you to understand the test cases for testing website cookies when you have a clear understanding of how cookies work, how cookies get stored on the hard drive, and how we can edit cookie settings.

What is an HTTP or Internet Cookie?

A web cookie is a small piece of information stored in a text file on the user’s hard drive by a web server. This information is later used by the web browser to retrieve information from that machine.

Generally, the cookie contains personalized user data or information that is used to communicate between different web pages.

WEBSITE COOKIE TESTING

Why are Web Cookies Used For?

Cookies are nothing but the user’s identity and are used to track where the user navigated throughout the website pages. The communication between the web browser and a web server is stateless.

For Example:

If you are accessing the domain “http://www.example.com/1.html” then the web browser will simply query the example.com web server for page 1.html.

Next time if you type the page as “http://www.example.com/2.html” then the new request will be sent to the example.com web server for sending 2.html page and the web server does not know anything about to whom the previous page 1.html was served.

What if you want the previous history of this user communication with the webserver? You need to maintain the user state and interaction between a web browser and a web server somewhere. This is where the cookie comes into the picture. Cookies serve the purpose of maintaining user interactions with a web server.

How Do Cookies Work?

The HTTP protocol used to exchange information files on the web is used to maintain the cookies.

There are two types of HTTP protocols. Stateless HTTP and Stateful HTTP protocol. The stateless HTTP protocol does not keep any record of the previously accessed web page history.

While the Stateful HTTP protocol does keep some history of previous web browser and web server interactions, this protocol is used by the cookies to maintain the user interactions.

Whenever a user visits a site or page that is using a cookie, the small code inside that HTML page (generally, a call to some language script to write the cookie like cookies in JAVAScript, PHP, Perl) writes a text file on the user’s machine called a cookie.

Here is an example of a code that is used to write a Cookie and can be placed on any HTML page:

Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME;

When a user visits the same page or domain at a later time this cookie is read from a disk and used to identify the second visit of the same user on that domain. The expiration time is set while writing the cookie. This time is decided by the application that is going to use the cookie.

Generally, two types of Cookies are written on the user machine

#1) Session Cookies: This cookie is active until the browser that invoked the cookie is open. When we close the browser this session cookie gets deleted. Sometimes a session of, say, 20 minutes can be set to expire the cookie.

#2) Persistent Cookies: These are cookies that are written permanently on the user’s machine and last for months or years.

Where are Cookies Stored?

When any web page application writes a cookie, then it gets saved in a text file on the user’s hard disk drive. The path where the cookies get stored depends upon the browser. Different browsers store cookies in different paths.

The below-mentioned paths are examples of where cookies are stored:

Internet Explorer: “C:\Users\username\AppData\Roaming\Microsoft\Windows\Cookies”.

Windows 7: “C:\Users\username\AppData\Roaming\Microsoft\Windows\Cookies\Low”.

Windows 8 and Windows 10: “C:\Users\username\AppData\Local\Microsoft\Windows\INetCookies”.

Here the “Default User” can be replaced by the current user you logged in as like “Administrator”, or username like “Vijay” etc. The cookie path can be easily found by navigating through the browser options.

In the Mozilla Firefox browser, you can even see the cookies in the browser option itself. Open the Mozilla browser, press the “Open menu” button? “Web Developer”? “Storage Inspector” or by pressing combination “Shift + F9”.

In the Google Chrome browser, you can find cookies by typing “chrome://settings/content/cookies” in your address bar. Cookies can also be accessed using the browser console: Press F12 –> application –> storage –> cookies.

How are Cookies Stored?

Take an example of a cookie written by rediff.com on the Mozilla Firefox browser. On the Mozilla Firefox browser, when you open the rediff.com page or log in to your Rediffmail account, a cookie will get written on your Hard disk.

To view this cookie, simply click on the “Show cookies” button mentioned in the above path. Click on the Rediff.com site under this cookie list.

You can see different Cookies written in the Rediff domain with different names.

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 cookies can be used:

#1) To implement the shopping cart: Cookies are used for maintaining an online ordering system. Cookies, remember what the user wants to buy. What if the user adds some products to their shopping cart and if due to some reason the user doesn’t want to buy those products this time and closes the browser window?

In the above instance, the next time the same user visits the purchase page, he can see all the products he added to the shopping cart during his last visit.

#2) Personalized sites: When a user visits a certain page, they are asked which pages they don’t want to visit or display. User options get stored in a cookie and until the user is online, those pages are not shown to him.

#3) User tracking: To track the number of unique visitors online at a particular time.

#4) Marketing: Some companies use cookies to display advertisements on user machines. Cookies control these advertisements. When and which advertisement should be shown? What is the interest of the user? What keywords do they search for on the site? All these things can be maintained using cookies.

#5) User sessions: Cookies can track user sessions to a particular domain using a user ID and password.

Drawbacks of Cookies

#1) Even writing a Cookie is a great way to maintain user interaction, if the user has set browser options to warn before writing any Cookies or disabled the Cookies completely then the site containing Cookie will be completely disabled and it cannot perform any operation thereby resulting in loss of site traffic. This can be disabled/enabled in your browser settings.

For Example: for google chrome, you need to go Setting -> Advanced -> Content Settings -> Cookies. There you can apply a general rule for Cookie policy, or set it for individual websites.

In addition to browser settings, there are some changes in regulations in the EU and US that force developers to warn a user that Cookies are used on the website. Compliance with such new regulations should also be a part of test scenarios for certain regions.

#2) Too many Cookies: If you are writing too many cookies on every page navigation and if the user has turned on an option to warn before writing the Cookie, this could even turn away user from your site.

#3) Security Issues: Sometimes, the users’ personal information is stored in Cookies and if someone hacks the Cookie then a hacker can get access to your personal information. Even corrupted cookies can be read by different domains and lead to security issues.

#4) Sensitive Information: Some sites may write and store your sensitive information in cookies, which indeed should not be allowed due to privacy concerns. This should be enough to know what Cookies are.

Test Cases for Web Application Cookie Testing

The first obvious test case is to test if your application is writing Cookies properly on disk. You can also use the Cookie Tester application if you don’t have any web application to test, but you must understand the Cookie concept for testing.

Some Major Test Cases for Web Application Cookie Testing

#1) As a Cookie privacy policy, make sure from your design documents that no personal or sensitive data is stored in the Cookie.

#2) If you have no option other than saving sensitive data in a Cookie, then make sure that the data stored in a cookie is stored in an encrypted format.

#3) Make sure that there is no overuse of cookies on your site under test. Overuse of cookies will annoy users if the browser is prompting for cookies more often and this could result in loss of site traffic and eventually loss of business.

#4) Disable the Cookies from your browser settings. If you are using cookies on your site, your site’s major functionality will not work by disabling the Cookies. Then try to access the website under test.

Navigate to the site to see if appropriate messages are displayed to the user like “For smooth functioning of this site, make sure that Cookies are enabled on your browser”.

No page should crash due to disabling Cookies. Make sure to close all browsers and delete all previously written cookies before performing this test.

#5) Accepts/Reject some cookies: The best way to check the website functionality is, not to accept all Cookies. If you are writing 10 Cookies on your web application then randomly accept some cookies, say accept 5 and reject 5 Cookies.

To execute the above test case, you can set the browser options to prompt whenever the Cookie is being written on disk. In this prompt window, you can either accept or reject the Cookie. Try to access the main functionality of the website and see if the pages are getting crashed or data is getting corrupted.

#6) Delete the Cookie: Allow the site to write the cookies and then close all browsers and manually delete all Cookies for a website under test. Access the web pages and check the behavior of the pages.

#7) Corrupt the Cookies: Corrupting a cookie is easy. As you know where the cookies are stored, you can manually edit the cookies in the notepad and change the parameters to some vague values like altering the cookie content, name of the cookie, or expiry date of the cookie and see the site functionality.

In some cases, corrupted cookies allow reading the data inside it for any other domain. This should not happen in the case of your website cookies. Note that if the cookies are written by one domain say rediff.com it can’t be accessed by another domain, say yahoo.com unless and until the cookies are corrupted and someone is trying to hack the cookie data.

#8 ) Checking the deletion of cookies from your web application page: Sometimes cookies written by a domain say rediff.com may be deleted by the same domain but by a different page under that domain. This is the general case if you are testing some ‘action tracking’ web portal.

Recommended reading => Methods to clear browser cache memory

Action tracking or purchase tracking pixel is placed on the action web page and when any action or purchase occurs by a user the Cookie written on disk gets deleted to avoid multiple actions logging from the same Cookie. Check if reaching your action or purchase page deletes the Cookie properly and no more invalid actions or purchases get logged from the same user.

#9) Cookie Testing on Multiple browsers: This is the most important case to check if your web application page is writing the cookies properly on different browsers as intended and the site works properly using these Cookies. You can test your web application on the most used browsers like Chrome, Internet Explorer, Mozilla Firefox, Netscape, Opera, etc.

#10) If your web application is using cookies to maintain the logging state of any user then log in to your web application using some username and password.

In many cases, you can see the logged-in user ID parameter directly in the browser address bar. Change this parameter to a different value, say if the previous user ID is 100 then make it 101 and press enter. Proper access messages should be displayed to the user and the user should not be able to see the other user’s account details.

#11) Verify if cookies are persistent or not (according to your requirements) by checking the cookie type and expiration dates in Cookie file or browser console

#12) Validate if an expiration date is set accordingly to requirements. In some cases, it is vital to check if the Cookie expiration date is updated by working with an application (to refresh session for example). This can be checked in the browser console or in the cookie file itself.

Please note that decoding a cookie manually is not the best approach and it is easier to rely on browser data, but if required – this thread contains some answers on the Cookie file format.

#13) If some cookies are user-specific, it is important to ensure that they are deleted or simply ignored if another user logs into the application unless it is said differently in the specification.

#14) Specific test for multi-environment sites: Check if the same cookies are acceptable in all environments. Issues could be caused by the use of wildcards in the cookie path (so-called supercookies). If this is a requirement to allow it, some access issues can be caused because a different encryption key is used (e.g for .Net, it is a machine key that is usually unique unless specified otherwise).

These are some of the major test cases to be considered while testing the website cookies. You can write multiple test cases from these test cases by performing various combinations. If you have a different application scenario, you can mention your test cases in the comments below.

Conclusion

By now you should have a clear understanding of how to perform website cookie testing and how to write test cases for testing web application cookies.

Please share your thoughts/queries in the comment section below. 

Was this helpful?

Thanks for your feedback!

Recommended Reading

293 thoughts on “Website Cookie Testing & Test Cases for Testing Web Application Cookies”

  1. Thank you for providing the such a great information. I have one question. In chrome where cookies will be stored (Please specify the path)

    Reply
  2. Thanks Vijay for this article. Now got clear idea of cookies. Earlier I was having lot confusion about cookies. Cookie info and test cases are very good..

    Reply
  3. hi,
    i’m nirmala doing final year IT.. i want to knw abt web based application n types of web testing with some examples..plz can u able to send to my mail..

    Reply
  4. hi..can anyone explain me the following
    1.example for writing test cases for web application
    2.i think the the test case table include test id,test scenario like that…tell me some example tables
    3.what are all the basic validations like login validation etc .help me out

    Reply
  5. How can we automate Persistent basket
    Example Scenario: User can able to add multiple products to the basket, leave the system for a period of time(1hour or couple of hours)and on user return to the website, user should be able to continue the checkout process and purchase the previously added items without having to re-add all of them to the basket.

    Please help me in this regard how can I test this efficiently

    Thanks
    Sri

    Reply
  6. hey this article fetched me lot of this thanks… could u please tell me how to know whether application is writing cookies r not?

    Reply
  7. Gr8 article , gets vital information regarding the cookies and the cookie testing and test cases for the same ! thanks man !

    Reply
  8. Hi,
    please could you give me
    1)Software testing questions and answers
    2)CSTE &CSQA exam related questions and answers

    email:podsevatkina.anastasia@gmail.com

    Reply
  9. Hi I want to test regarding cookies..
    Session should be good for 4 hours and once expired user is returned to login page..

    How can i test the session is good for 4 hrs??
    Whether i need wait for 4 hours?

    Reply
  10. I will be happy to know how one can identify phishing mail particularly bank phishing mails with the help of cookies and privacy policy of the website.

    Reply
  11. A very good article, giving a clear picture of cookies and its related information. Do post information on some other useful topics as well.

    Reply
  12. hi..can anyone explain me the following
    1.example for writing test cases for web application
    2.i think the the test case table include test id,test scenario like that…tell me some example tables
    3.what are all the basic validations like login validation etc .help me out…..
    send me via e-mail

    Reply
  13. Hi,
    I want to know answer of this question “how to check security of any browser ? give me some example”.

    Please reply me.

    Reply
  14. Very usefull information on cookies. I think it will be helpful in interviews who asks some basic questions on cookies.

    As I am very new to this cookies, I felt i learnt alot.

    I has one basic question, how user will come to know the website which he is working uses cookies to identify the user?

    Thanks in advance for the replies

    Reply
  15. As part of security testing, got to know tester has to check httponly and secure tags in cookies. Please let us know how can be this tested manually?

    Reply
  16. I wanted to know how can I verify the information stored in a cookie. I tried cookie extension however i could not read it. As per my exploration, cookies in chrome are encrypted and they are in SQL Lite DB file. What are the ways to know what is stored inside the cookie?

    Reply
  17. Hi,I want to know that which automation tool is best in software testing (Mercury or rational).And how much is required to be done perfectly.

    Reply
  18. Thank you so much. This article has really been helpful for me in getting an insight into the concept of cookies and its relevance to e-commerce sites.
    Thanks again.

    Reply
  19. Hi

    Currently I am working on Web Based application ,where we have written test cases,now we r in the process of automating the test cases.could u kindly sugest with an example how to create a test bed?

    Reply
  20. hi everyone,
    i am a fresher to testing domain(manual) & got job recently in some MNC comp, & ryt now i am on bench,,kindly help me some1 wt soft skills i should improve in order to have a rapid growth in this domain,,,,pls do reply,,,,,

    Reply
  21. Thanks a lot for sharing a great information like this with us.Now I am able to clear many doubts about cookies from this article.
    it’s really a great work.

    Reply
  22. Hi friends please help me

    Can any of you give me good topic for presentation in Software testing.
    Suggest me some good interesting topic

    Cheers Pavitra

    Reply
  23. hi, I have confusion regarding “Validation and functional”…. Like for any home page if i would like to write functional cases then do i have to write that when i click on the next button then it must mavigate to next button or is this for validation…….. please help me out ?
    Thanks

    Reply
  24. Really it’s a exellent information. Now I clearly comes to Know What is Cookies. My Long time search has concluded. Thank You Very Much 🙂

    Reply
  25. Hi Vijay
    Thanks for sharing valuable information regarding cookies
    These wll be very useful for me in web site testing
    Thanks once again and update new issues

    Reply
  26. Nice atrical to Test Cookies.
    Well I have started working on security Testing if anybody want to learn or something else then I am open for you guys….

    Reply
  27. Is is necessary to check or cookies? If i don’t have a login panel in my website then in that case what i have to do dear? Should i ignore this testing?

    Reply
  28. cheers,
    great article about cookies – vijay,but i want to know ever u came across cookies which are executable.

    Reply
  29. Navneet, Website security is a very wide topic. A persistent cookie could also pose threat to the security of the website. Another example is cross site scripting, where the hackers can inject some code/ images on the client browser through Java script. An interesting part is Data security. For e.g the user data like credit card details etc shouldn’t be passed in GET request but POST and the page should be HTTPS…The testers cannot do a fool-proof security testing but just so much to ensure the website is secure. WEBINSPECT is a tool by HP which is used to carry out security audit of websites. IT generates a very extensive report and helps understand the security vulnerabilitites of the website under test..Hope this helps..

    Reply
  30. really above information is really help full, i m manual tester but i havent any idea about the cookie , now i m able to test cookie, and face the interview

    Reply
  31. Can anyone in this forum give me the site where I can download useful question and articles Testing related on Client Server and N-tier applications.

    Reply
  32. Hi,
    Thanks.
    Really the article is helpful. Could u guide me how to prepare for CSTP. Pls. suggest me where to get dumps and course ware.

    Reply
  33. Thanks Raja, I’m intrested in learning the security testing concepts. Could you let me know the best book/ site around for learning security testing concepts

    Reply
  34. vijay how to corrupt cookies in mozilla…i am not able to edit the content..please explain the process of editing in mozilla

    Reply
  35. There are few browser plugins through which we can directly edit cookie, can anyone suggest me the best among them?

    Reply
  36. Hey it was very help full to understand that “what is cookies??” Can u give me some code to develop a testing application????
    Thanks a lot….

    Reply
  37. hi,
    Very Good Article.
    ITs very helpful.

    Can you give me a test cases of AJAX testing I am facing problems.
    Need to help

    Reply
  38. hi, appreciate if anyone can send me some sample test cases for web testing along with their build life cycle .

    Also the same for some client server application.

    I am new in testing .

    Reply
  39. Hi,
    This was a very good article…but I want to know how do we test corrupting the cookie…
    Can you please explain how do we corrupt the cookie and do the testing…

    Reply
  40. very good article

    Can you please help in Data base testing I am facing problems
    every time I need to test from the beginig
    as the files inthe database are replacing
    I can’t able to figure it out where the exact problem occuring

    regards
    Ajay

    Reply
  41. Hi,
    I need sample test cases for testing web aplication(developed using RUBY ON RAILS).Backend is Sybase.Before OS is Linux 4.7 and we are going to upgrade the OS(Red hat Linux).What are all the things i need to test this web application after OS upgrade.Also i need test cases for testing web application .kindly help me

    Reply
  42. HI,
    This is Goverdhan
    Pls could u give me
    1)Software testing questions and answers.
    2)CSTE&CSQA exam related model questions and answers.

    email:govardhan6@gmail.com

    Reply
  43. Hi vijay,

    Can you please tell me if the my application is using the cookie while login or not based on the senario explained below:

    If the cookies is enabled and logged in no cookies were created in the cookie folder. But when the cookies were blocked and then tried to access it threw an exception. “Object reference not set to instance of the object”

    thanks in advance

    Reply
  44. Hey really its very good and helpful.Since long time i am searching on this as want to know about this.By reading your article it clears all my queries.

    Thanks a Lot!!

    Reply
    • After thanks word there is no question.
      I just used three emojis that are not displayed, instead ??? are displayed.

      Reply
  45. i want to knew the procedure fallowed for the web based testing and client server testing.

    Reply
  46. Hi,I want to know that which automation tool is best in software testing (Mercury or rational).And how much is time is required to be done perfectly.

    Reply
  47. I am G.Balaji working as a test engineer in agriya infoway
    i am testing web application developed by php and mysql
    i want to know about the domain knowledge is very important for tester or not
    and also i want the details of ISQTB certification(foundation level ) and books regarding that exam

    Reply
  48. Is there is problem with Google Chrome..I am testing one site and whenever i tries to open that site in all other browsers it works fine but in Chrome i am unable to open that link.

    Reply
  49. COOKIES TESTING IS VERY MUCH NEEDED LIKE OTHER PARTS OF WEB APPLICATIONS. YOU HAVE NOTED DOWN SOME GOOD POINTS THAT CAN BE INTEGRATED IN WRITING TEST CASES.. GOOD JOB..

    Reply
  50. It’s very good site that would be helpful for the testers. i appriacte the topics coverd and giving in details information.

    Reply
  51. Hi,
    pls could u give me
    1)Software testing questions and answers
    2)CSTE &CSQA exam related questions and answers

    email:fish_sr2005@yahoo.com

    Reply
  52. while doing security testing make sure you test for ,
    authorization, data access, authentication, cross site scripting-XSS and SQL injection, i am sure as a security tester, there are lot of bugs u can find in ur project only using many xss scripts and doing sql injections. try giving alert(“hi, this will work for you”)

    Reply
  53. Hi,
    I am working on QTP. i wan to automate Outlook functionality(e.g.Sending Mails, Read the Mails, count Unread mials in Inbox.etc……)
    I just want to know the function for Counting Unread mails from Inbox. Reply back to me if anyone knows the same.

    Thanks,
    Purushotham Reddy.

    Reply
  54. Great work dude, this whole stuff is really helpful for beginners as well as the advanced professionals.
    Keep it up man

    Reply
  55. Thanx it is very helpful and it is very useful for the fresher test engineer, it also clears basic concept of cookies.

    Reply
  56. This is a very good article, cookies play very important role in maintaining user data especially in web applications. As the security concerns are becoming more critical for banking & financial web application, cookies help in tracking the frauds. My kind suggestion to all my Tester friends working on Banking & Security domain that they must perform the cookie testing & application performance under different cookie scenario, to make their application robust & perfect.
    Special thanks to the writer.
    Thanks.

    Reply
  57. Am facing scenarios where am always told by the developers to delete the cookies and then validate the application. And after I delete the cookies then the functionality works. But below is my concern,
    Q) will the end user/customer delete the cookies to perform his actions ?

    Any reply would be greatly helpful and i can work with my developers accordingly.

    Reply
  58. With the release of DNN 4.5.2 and the associated fixes to the AJAX implementation I thought i would revisit my “Core Modules” and AJAX testing that I had completed after the release of 4.5.0. The good news is that more modules can support AJAX since the issues with the URL Control have been resolved. This article will discusss individual modules and the functionality that is now available with the release of 4.5.2.

    Reply
  59. Hi this very well compiled article about website cookies testing.
    Thanks for share with us and thanks for all who commented here and found some useful links and test cases from there as well.

    Reply
  60. Great work and information sharing, this whole stuff is really helpful for beginners as well as the advanced professionals ans also for maintaining quality of service.

    Reply
  61. Thanks for the great article. I am doing some self-study on testing, and tried to carry out cookie testing after reading this article. But I am not able to locate and edit cookies. I have Mac OS X Yosemite. Please help me with this. Or it is only possible to edit cookies on server operating systems?

    Reply

Leave a Comment