GetCookie Method

Syntax

Context.Request.GetCookie as A (CookieName as C)

Arguments

CookieNameCharacter

The name of the cookie to fetch.

Returns

ResultSystem::Web::HttpCookienull_value()

Returns a System::Web::HttpCookie object if the cookie exists, otherwise returns a null value.

Description

Returns a cookie if the cookie exists.

Discussion

Context.Request.GetCookie returns a System::Web::HttpCookie object if the cookie exists. If the cookie does not exist, Context.Request.GetCookie returns a null value.

dim cookieName as c = "myCookie"

cookie = Context.Request.GetCookie(cookieName)

'test the cookie for a null value.
if (cookie == null_value()) then
    ? "Cookie does not exist!"
else 
    ? cookie.Name + " has a value of " + cookie.Value
end if

In addition to using the null_value() method, you can alternatively compare the type of the variable returned by Context.Request.GetCookie to "Z", the null data type:

if (typeof(cookie) == "Z") then
? "Cookie does not exist!"
end if

See Also