Skip to content

HTMLUnit does not seem to set the Cookie value in JS  #270

@vasucomandur

Description

@vasucomandur

The Javascript function Called to set the cookie is given below
setCookie("JDSessionID",'324130607618582600',now,path, "jobdiva.com");

The values for now and path are given below:
var now = new Date();
// cookie expires in one year (actually, 365 days)
now.setTime(now.getTime() + 500 * 24 * 60 * 60 * 1000);
var path="/";

The actual method is copied below for your reference

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((IExplorerAgent) ? "" : "; SameSite=Lax") +
((secure) ? "; secure" : "");
//alert("path="+path);
//alert("domain="+domain);
// console.log("curCookie: " + curCookie);
document.cookie = curCookie;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions