Kaya 0.5.3 reference for WebCommon::setCookie

List of functions and data types in WebCommon

Pair<String, String> setCookie(String key, String value, Maybe<Time> expires=nothing, Maybe<String> path=nothing, Maybe<String> domain=nothing, Bool secure=false)

Arguments

Usage

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 test.server.example.com.

Related

kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya