WebRequest.SetCookie

From Xojo Documentation

Method

WebRequest.SetCookie(Name As String, Value As String, Expiration As Date = Nil, Domain As String = ".", Path As String = "/")

New in 2011r2

Supported for all project types and targets.

Adds a new cookie to the response using the specified Name and Value. Cookies are name/value pairs, similar to a Dictionary. The Expiration, Domain, and Path parameters are all optional.

Notes

Leaving the Expiration as nil will result in a cookie that is valid as long as the user does not close their browser. Once the browser is closed, the cookie is discarded.

Leaving the Domain as "." will result in a cookie that is valid for the current domain, including subdomain. If the current domain is http://subdomain.mydomain.com/, the cookie will be valid for only http://subdomain.mydomain.com/ and not http://www.mydomain.com/. To create a cookie valid for any subdomain, set domain to ".mydomain.com" substituting your own domain of course. It is not possible to set a cookie for another domain, the browser should reject it.

Leaving the Path as "/" will result in a cookie valid for the entire domain specified in the Domain parameter. To create a cookie valid only for paths inside the /special/ directory for example, set the value to "/special/".

See Also

WebRequest.ClearCookie, WebRequest.GetCookie