1WebCommon.setCookie(3kaya) Kaya module reference WebCommon.setCookie(3kaya)
2
3
4
6 WebCommon::setCookie - Create a cookie header
7
9 Pair<String, String> setCookie( String key, String value, Maybe<Time>
10 expires=nothing, Maybe<String> path=nothing, Maybe<String>
11 domain=nothing, Bool secure=false )
12
14 key The name of the cookie
15
16 value The value of the cookie
17
18 expires The time that the cookie expires, which must be in GMT, or
19 nothing if the cookie is a "session cookie" that expires when the web
20 browser is closed (the default).
21
22 path The URL path to which the cookie will be returned. The default is
23 nothing which sets it to the URL path of the current document. The URL
24 path must begin with a '/' if it is explicitly set.
25
26 domain The domain that the cookies will be sent to. The default of
27 nothing gives the current hostname.
28
29 secure If true (the default is false) this cookie will only be sent
30 back to the server over HTTPS connections. Use this if the cookie con‐
31 tains or can be used to access any sensitive information unless you do
32 not have HTTPS available.
33
35 Creates a cookie header that can be passed to HTMLDocument.addHTTP‐
36 Header (3kaya) or added to the headers list for functions such as
37 Webapp.displayPage_1 (3kaya)
38 Remember that cookies are not available in the page that sets them,
39 since the web browser has not yet received them to send back at that
40 point.
41
42
43 expires = gmTime(time()+3600); // one hour later
44 cookie = setCookie("session",newSession(),just(expires));
45 addHTTPHeader(doc,cookie);
46
47 The original Netscape cookie specification
48 ⟨http://wp.netscape.com/newsref/std/cookie_spec.html⟩ has more detail
49 on the use of these fields.
50
51 The functioning of the domain part is sometimes problematic. For exam‐
52 ple, there is no way to set a cookie that should be returned to
53 server.example.com but not to test.server.example.com
54
55
57 Kaya standard library by Edwin Brady, Chris Morris and others
58 (kaya@kayalang.org). For further information see http://kayalang.org/
59
61 The Kaya standard library is free software; you can redistribute it
62 and/or modify it under the terms of the GNU Lesser General Public
63 License (version 2.1 or any later version) as published by the Free
64 Software Foundation.
65
67 CGI.header (3kaya)
68 HTMLDocument.addHTTPHeader (3kaya)
69 Webapp.displayPage_1 (3kaya)
70
71
72
73Kaya December 2010 WebCommon.setCookie(3kaya)