How should a global cookie work on xPages?

How should a global cookie work on xPages? This is a map, so I can easily check the existence of a cookie, but how do I create a new cookie? Using cookie.name = "value" throws an error because it is assumed that the cookie must be some kind of object with parameters such as expiration, etc. But what kind of object is it? I cannot find suitable documentation for this, or I missed something.

+3
source share
3 answers

A cookie is a map of the cookie values ​​of an instance request . Therefore, you cannot use it because “setting a cookie” means “adding a cookie to the response”.

So, as follows from the article, you should use the response object.

var response = facesContext.getExternalContext().getResponse(); 
var userCookie = new javax.servlet.http.Cookie("name", "value"); 
userCookie.setMaxAge(60*60*24*365*10); // set age in seconds...
userCookie.setPath("/"); // cookie will be valid under this path
response.addCookie(userCookie);
+6
source

I can’t give an answer to the global cookie, but the following article shows how to manage cookies in XPages using the javax.servlet.http.Cookie class:

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/cookie-management.html

Maybe a global cookie expects an object of type javax.servlet.http.Cookie?

+2
source

Set-Cookie?

0

All Articles