Skip to Content
0
Dec 28, 2022 at 04:54 PM

Why can't I get cookies' values in XSJS?

134 Views

Hi experts,

I'm trying to get the login cookies within my XSJS, but the values I get from $.request.cookies are empty.


For instance, look at this sample code:

let output = "";
for (let name in $.request.cookies) {
output += "name:" + name + ",value" + JSON.stringify(cookies[name]) + "<br>"; } $.response.contentType = "text/html"; $.response.setBody(output);

After login, the browser shows:

name:0,value:{"name":"xsIdD2BEE...", value:""}
name:1,value:{"name":"sapxslb",value:""}

Which means I can get cookies' keys ("xsIdD2BEE" and "sapxslb"), but cookies' values are empty.

I can see the values in chrome's developer panel and they are not empty.

Can any one tell me how can I get cookies' values?

Thank you very much in advance!