/* SAMPLE CGI TO show GET and PUT of Cookies */
'GETARGS'
If parm.0 = 0
 Then call = 'SET'
 Else call = parm.1
UPPER call
 
'OUTPUT' '<HTML><TITLE>Sample of a Cookie 'call'</TITLE><BODY>'
 
Select;
 
 When call = 'GET' Then
   Do;
     'GET_COOKIE'
     If rc ^= 0 Then
       'output' '<br>No cookies found for this path'
     Else
       Do i = 1 to cookie.0
        'output' '<br>Cookie nbr' i || ':' cookie.i
      End
  End;
 
 When call = 'SET' Then
   Do i = 1 to 3
     data = '"Cookie number' i 'Cookie test data"'
     cookiename = 'test' || i
     'SET_COOKIE name' cookiename 'path / data' data
      If rc = 0 Then
        'output' '<br>Cookie is SET to 'data
      Else
        'output' '<br>Unable to SET cookie' I 'rc=' rc
   End;
 
 When call = 'DISP' Then /* display code */
   Do;
     lcnt = Sourceline()
     Do I = 1 to lcnt
       iline.i = sourceline(i)
     End
     iline.0 = lcnt
     'output' '<pre>'
 
     Address CMS 'PIPE stem iline.',
              '| change /</ /</ | change />/ />/ ',
              '| output'
     'output' '</pre>'
 
   End;
 
 Otherwise
   'OUTPUT' 'Unknown call'
 
End;
 
'OUTPUT' '</BODY></HTML>'
 
EXIT 0