wwRequest::GetCookie

Returns an HTTP Cookie that was previously set. HTTP cookies allow keeping state by keeping a persistent variable on the user's browser. Cookies are sent along in each HTTP request and appear as a server variable in the incoming request data.

To set a cookie you need to use the wwHTTPHeader::AddCookie method to assign a cookie as part of the HTTP header for a returned request.

Also see the How To section for Implementing HTTP Cookies.

o.getcookie(lcCookie)

Return Value

String of the cookies contents.

Parameters

lcCookie
The name of the cookie to retrieve

Remarks

Cookies are scoped to a particular virtual directory, so a cookie set in a different virtual than the one the current request is running in will not be visible.

Although cookies follow the directory hierarchy down, a Cookie set in the root directory will also not be in scope in a virtual below the root, but will be in scope in a dircectory below the root that is not a virutal.

Example

*** Try to retrieve the cookie...
lcId=Request.GetCookie("WWUSERID")

*** Create Standard Header
loHeader=CREATEOBJECT("wwHTTPHeader")
loHeader.DefaultHeader()

*** If not Found
IF EMPTY(lcId)
   *** Create the cookie
   lcId=SYS(3)
   
   loHeader.AddCookie("WWUSERID",lcId,"/wconnect")
   
   *** To specify a permanent cookie supply NEVER or a specific expiration date
   *** loHeader.AddCookie("WWUSERID",lcId,"/","NEVER")
ENDIF            

*** Send Header and make sure to pass the Content Type (loHeader)
Response.ContentTypeHeader(oHeader)

*** more html
Response.Write("<HTML>Hidi ho</HTML>")


*** OR: use one of the following methods which take a header parameter: Response.HTMLHeader("Hidi ho",,,oHeader) Response.ExpandTemplate(THIS.cHTMLPagePath + "nocode.wc",oHeader) Response.ExpandScript(THIS.cHTMLPagePath + "nocode.wcs",oHeader)

See also:

Class wwrequest

© West Wind Technologies, 1996-2019 • Updated: 10/08/01
Comment or report problem with topic