The ocookies object
Complementary to the icookies object that provides access to HTTP cookies sent by the client, Woof also provides the ocookies object which allows the application a convenient means of manipulating HTTP cookies on the client. This object, belonging to class CookiesOut, provides an interface for setting values, as well as attributes, for cookies. When the response is sent to a client, Woof! will automatically include Set-Cookie headers to set the values for all keys defined in the ocookies object. Below are some examples where the cookie name is cname and value is cvalue.
Setting a cookie value
ocookies set cname cvalue
This is the simplest case of setting a cookie value. All cookie attributes take their default values.
Setting a cookie with an expiry time
ocookies setwithattr cname cvalue -expires [clock add [clock seconds] 1 hour 30 minutes]
In this example, we set the cookie to expire after an hour and a half making use of Tcl's clock command.
Setting a cookie to never expire
ocookies setwithattr cname cvalue -expires never
Here the cookie will stick around until the user explicitly deletes it.
Deleting a cookie
ocookies setwithattr cname cvalue -expires now
Setting the cookie to expire right way will effectively cause the browser to delete it.
Restricting a cookie to be specific to a domain
ocookies setwithattr cname cvalue -domain yourdomain.com
Restricting the cookie to a specific domain will cause the browser to send the cookie in requests to servers belonging to that domain.