KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Setting HTTP Status and Cookie
PRODUCT: 4D | VERSION: 6.7 | PLATFORM: Mac & Win
Published On: November 2, 2001

It is possible to set the HTTP Status (200 OK, 401 Unauthorized, 302 Moved Temporarily, etc.) using SET HTTP HEADER. It is also possible to set an HTTP Cookie with SET HTTP HEADER. If you wish to set the status _and_ set a Cookie at the same time, you must set the Status before you set the cookie.

Example:

ARRAY TEXT($atName;4)
ARRAY TEXT($atValue;4)

$atName{1}:="X-VERSION"
$atName{1}:="HTTP/1.0"

$atName{2}:="X-STATUS"
$atValue{2}:="401 Unauthorized"

$atName{3}:="WWW-Authenticate"
$atName{3}:="Basic realm="+Char(Double Quote)+"my_database"+Char(Double Quote)

$atName{4}:="Set-Cookie"
$atName{4}:="name=mycookie; expires=Thu, 18-Oct-2001 09:32:19 GMT; path=/;"

SET HTTP HEADER($atName;$atValue)

Note that the cookie is the last header to be set.