Search code examples
cookiesxpagesserverside-javascriptssjs

how to get the path of cookies using ssjs?


I am trying to get the path of a cookie

I have several cookies with the same name but with different paths.

The following example return null using the getpath() method

var request = facesContext.getExternalContext().getRequest(); 
var cookies = request.getCookies();
print(cookies[1].getName()))
print(cookies[1].getPath()))

I also tried the global object "cookie" in xpages but how do I get the path from that?

How can I get the path of all the cookies using ssjs?

enter image description here


Solution

  • You can't. Googled a bit. Seems to be a common problem beyond Domino and XPages. Both getDomain and getPath return null, because browser does not send it to the server. Explained here getDomain() of javax.servlet.http.Cookie is returning null

    Also a short thought here https://coderanch.com/t/283519/java/Cookie-getDomain-returns-null that it may be security feature.