Pair<String, String> setCookie(String key, String value, Maybe<Time> expires=nothing, Maybe<String> path=nothing, Maybe<String> domain=nothing, Bool secure=false)
key: The name of the cookie
value: The value of the cookie
expires: The time that the cookie expires, which must be in GMT, or
nothingif the cookie is a "session cookie" that expires when the web browser is closed (the default).
path: The URL path to which the cookie will be returned. The default is
nothingwhich sets it to the URL path of the current document. The URL path must begin with a '/' if it is explicitly set.
domain: The domain that the cookies will be sent to. The default of
nothinggives the current hostname.
secure: If true (the default is false) this cookie will only be sent back to the server over HTTPS connections. Use this if the cookie contains or can be used to access any sensitive information unless you do not have HTTPS available.
Creates a cookie header that can be passed to HTMLDocument::addHTTPHeader or added to the headers list for functions such as Webapp::displayPage. Remember that cookies are not available in the page that sets them, since the web browser has not yet received them to send back at that point.
expires = gmTime(time()+3600); // one hour later cookie = setCookie("session",newSession(),just(expires)); addHTTPHeader(doc,cookie);
The original Netscape cookie specification has more detail on the use of these fields.
The functioning of the
domain part is sometimes problematic. For example, there is no way to set a cookie that should be returned to
server.example.com but not to