HttpObjectSetCookieAttribute

function

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

Declaration
define function HttpObjectSetCookieAttribute
               modifiable  stream HttpObject
   for         value       stream CookieName
   attribute   value       stream AttrName
   to          value       stream AttrValue

Argument definitions

HttpObject
is an HTTP request or HTTP response object (input argument).
CookieName
is the name of the cookie. Note that any preceding "$" symbol should be omitted (input argument).
AttrName
is the name of the cookie attribute (input argument).
AttrValue
is the value to assign to the cookie attribute (input argument).


Purpose

Use HttpObjectSetCookieAttribute to set a named attribute value for a cookie header 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

If a nonexistent cookie name is specified, the HTTP object will be in error. Usually, HttpObjectSetCookieAttribute is called in a server program.

Examples

Set both request and response cookie attributes.


  ; HttpObjectSetCookieAttribute
  include "omhttp.xin"
  
  process
  
     local HttpRequest my-Request
     local HttpResponse my-Response
  
     HttpObjectSetCookieAttribute my-Request
        for "DocUserID" attribute "Domain" to "www.stilo.com"
     HttpObjectSetCookieAttribute my-Response
        for "DocUserID" attribute "Domain" to "www.stilo.com"

Create a function to set cookie attributes.


  include "omhttp.xin"
  
  define function SetUserIdCookie
    (modifiable stream http-object,
     value      stream cookie-name,
     value      stream cookie-value,
     value      stream user-id)
  as
    HttpObjectSetCookieValue http-object for cookie-name to user-id
    HttpObjectSetCookieAttribute http-object
      for cookie-name attribute "Domain" to "www.stilo.com"
    HttpObjectSetCookieAttribute http-object
      for cookie-name attribute 'Path' to '/'

The following line calls the above function:


  SetUserIdCookie(my-http-object, cookie-name, cookie-value, user-id)