• A cookie is a small piece of data or information between a server-side and a client-side. A web browser stores that piece of data when the user is browsing something. In qa testing services , generated cookies are utilized for different purposes.

    A cookie contains the information as a string in the form of a name-value combination separated by semi-colons; say "Username-XYZ". It remembers the user's information among all the web pages. JavaScript Cookies are an efficient way to save a user's choices from the browser.

    Cookies were invented to overcome the problem that how we can store or remember the information about the user. When a user visits a web page, the username gets stored in form of a cookie and next time when the same user visits the page, the cookie knows the username.

    JavaScript: How to set Cookies

    while browsing a session, the browser stores the cookies in memory, and at the end of session they got the file called as cookies.txt. Cookies files are stored in browsers at different location in the disk.

    Creating cookie in JavaScript
    In JavaScript, we can create, read, update and delete a cookie by using document.cookie property.

    Syntax: document.cookie="name=value"; 
    example: document.cookie = "username=XYZ";

    Cookie Attributes
    1. Expires: It tells us about expiration date for that cookie specified with date and time.
    2. Max-age: This attribute is maintain for the deciding the expiration time of the cookie. Here, time in seconds. It can be used in place of expires.
    3. Path: It expands the scope of the cookie to all the pages of a website.
    4. Domain: Used to specify the domain for which the cookie is valid.

    We can also set the expiration of the created cookie,
    document.cookie = "username=XYZ; expires=Thu, 10 Dec 2020 12:00:00 UTC";

    Reading a Cookie with JavaScript
    With JavaScript, cookies can be read with the document.cookie property:

    var x = document.cookie;
    document.cookie will return all the stored cookies in one string: cookie1=value; cookie2=value; cookie3=value;

    Deleting a Cookie with Javascript
    for deleting any existing cookie, we just need to set the value of the cookie to empty and set the value of expires to any of the passed date.

    document.cookie = "cookiename= ; expires = Thu, 01 Jan 2019 00:00:00 GMT"

    The Best Software Testing Services Company - QASource
    QASource is the leading software app testing company that provides comprehensive and custom software testing solutions. Get started today with a free…
This reply was deleted.
    results->result as $result) { ?>
  1. jobtitle;?>
    company;?>(formattedRelativeTime;?>)city;?>, state;?>
    Welcome to Mobile QA Zone, a Next Generation Software Testing Community.Invite your friends to join this community.Write to us to become a featured member.