Q:

Why does cookie get cleared automtically in JavaScript

I am trying to read cookie through JavaScript but after complete the process of reading cookie getting cleared, I don't want to clear cookie please help me to avoid this problem.
Following is the code to read cookie, it reads cookie and assign its value to text area element on the page
function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) 
                c_end = document.cookie.length;
            //return unescape(document.cookie.substring(c_start, c_end));
            return decodeURIComponent(document.cookie.substring(c_start, c_end));

        }
    }
    return "";
}

try{

    var readCount=parseInt(getCookie("count_cookie"));
    var quty=document.getElementById("quantity").value;
    var custom_data=""

    for(i=1;i<=readCount;i++)
    {
        cookName="Pdf_"+i;
        pdfname=getCookie(cookName);

        pdfname=pdfname.split("::");

        custom_data=custom_data+"Sku:= "+pdfname[0]+" Pdf Name:= "+pdfname[1]+" Quantity:= "+quty+"    ";

        setCookie(cookName,"");
    }

    document.getElementById("Textarea1").innerHTML=custom_data;

    }catch(e){
        alert(e.message);
    }

A:

What is this line doing exactly?
setCookie(cookName,"");

