com.HTTPServiceRequest.setResponseCookies

Allows the server to return cookies to be set on the client application sending the request.

Syntax

setResponseCookies(
   cookies RECORD  )
  1. cookies defines a dynamic array for the cookies to be set. See WSHelper variables and records for more information regarding WSServerCookiesType.

Usage

Allows the server to return cookies to be set on the client application sending the request.

In case of error, the method throws an exception and sets the STATUS variable. Depending on the error, a human-readable description of the problem is available in the SQLCA.SQLERRM register. See Error handling in GWS calls (STATUS).

Setting cookies example

IMPORT FGL WSHelper

DEFINE cookies WSHelper.WSServerCookiesType

# Set first cookie named 'CookieName'
LET cookies[1].name = "CookieName"
LET cookies[1].value = "AnyValue"
LET cookies[1].expires = now + INTERVAL (5) MINUTE TO MINUTRE

# Set second cookie named 'SecondCookie'
LET cookies[2].name = "SecondCookie
LET cookies[2].value = "AnotherValue"

# Set all cookies defined in the cookie array
CALL req.setResponseCookies(cookies)
CALL req.sendTextResponse(200, NULL, "Hello world")