HttpObjectSetCookieValue

function

Library: HTTP support (OMHTTP)
Include: omhttp.xin

Declaration
define function HttpObjectSetCookieValue
            modifiable  stream HttpObject
   for      value       stream CookieName
   to       value       stream CookieValue

Argument definitions

HttpObject
is an HTTP request or HTTP response object (input argument).
CookieName
is the name of the cookie (input argument).
CookieValue
is the value to assign to the cookie (input argument).


Purpose

Use HttpObjectSetCookieValue to set a named cookie value in an HTTP request or response object.

Requirements

You must include the following line at the beginning of your OmniMark program:


  include "omhttp.xin"

Usage Notes

Usually, HttpObjectSetCookieValue is called in a server program.

Examples


  ; HttpObjectSetCookieValue
  include "omhttp.xin"
  
  process
  
     local HttpRequest my-Request
     local HttpResponse my-Response
  
     HttpObjectSetCookieValue my-Request for "DocUserID" to "123abc456"
     HttpObjectSetCookieValue my-Response for "DocUserID" to "123abc456"

Set cookie values and list them:


  ;HttpObjectSetCookieValue Example 2
  
  include "omhttp.xin"
  
  process
  
     local HttpRequest my-Request
     local HttpResponse my-Response
     local stream request-Cookies variable
     local stream response-Cookies variable
  
     HttpObjectSetCookieValue my-Request for "DocUserID" to "123abc456"
     HttpObjectSetCookieValue my-Response for "DocUserID" to "123abc456"
  
     HttpObjectGetCookieValues my-Request into request-Cookies
     HttpObjectGetCookieValues my-Response into response-Cookies
  
     output "Request cookies:%n"
     repeat over request-Cookies
        output key of request-Cookies || "=%g(request-Cookies)%n"
     again
     output "%nResponse cookies:%n"
     repeat over response-Cookies
        output key of response-Cookies || "=%g(response-Cookies)%n"
     again