Class wwCookie

This is a support class for the wwPageResponse::AddCookie() method to allow setting cookie options more cleanly than the older way of passing a long list of parameters.

To set a cookie in this way use code like the following:

loCookie = CREATEOBJECT("wwCookie")

loCookie.CookieName = "testvalue"
loCookie.Value = "NewValue"
loCookie.Expires = DATE() + 10
loCookie.SameSite = "Strict"
loCookie.Secure = .T.
loCookie.HttpOnly = .T.

* ? loCookie.ToString()  && outputs the generated cookie string

*** Pass the cookie to set on the current request
Response.AddCookie(loCookie)

which produces a cookie string that looks like this:

testvalue=NewValue; path=/; SameSite=None; HttpOnly; Secure; Expires=Sun, 10 Nov 2019 10:00:00 GMT

Class Members

MemberDescription

Init

Initializes the cookie with optional name and value.

o.Init(lcName, lcValue)

CookieName

The name of the cookie.

Domain

Optional - the domain that the cookie applies to. This is optional and by default the current host's domain is used.

Expires

Optional - Date when the cookie expires.

ExtraContent

Optional - Allows adding explicit content to the end of the Cookie string generated.

HttpOnly

Optional - If set cookie can not be accessed programmatically on the client.

Path

Optional - the site path that the Cookie is scoped to.

SameSite

Optional - Sets the SameSite flag.

Secure

Optional - if set the cookie is sent only if the request is over HTTPS.

Value

The actual value that is stored in the cookie as a string.

See also:

Class wwCookie

© West Wind Technologies, 1996-2024 • Updated: 06/03/2020
Comment or report problem with topic