topical media & game development

talk show tell print

lib-ch-example-ref-cgi-addCookie.ch / ch



  #!/bin/ch
  /* Copyright (c) 2001 by SoftIntegration, Inc. All Rights Reserved */
  include <stdio.h>
  include <cgi.h>
  int main() 
  {
    class CCookie ck, ck2;
    class CResponse Response;
  
    // put Cookie with name of testCookie, key of CookieKey and value of Cookievalue
    ck.setName("testCookie");
    ck.setPath("/");
    ck.setValue("CookieValue");
    ck.setMaxAge(600);
    ck.setDomain("com");
    ck.setSecure(false);
  /* 
  Because there is no browser to support the following properties as yet,
  it is not recommended to use them.  
  
    ck.setVersion(1);
    ck.addPort(8080);
    ck.addPort(8081);
    ck.addPort(8082);
    ck.setComment("This cookie is for test");
    ck.setCommentURL("mailto:someone@example.com");
    ck.setDiscard(false);
  */
    Response.addCookie(&ck);
  
    ck2.setName("testCookie2");
    ck2.setPath("/");
    ck2.setValue("CookieValue2");
    //ck.setPath("/cgi-bin/ch/lang/demos/ref");
  /*
    ck2.setVersion(1);
    ck2.setMaxAge(600);
    ck2.addPort(8080);
    ck2.addPort(8081);
    ck2.addPort(8082);
    ck2.setComment("This cookie is for test");
    ck2.setCommentURL("mailto:someone@example.com");
    ck2.setDiscard(false);
    ck2.setDomain("example.dom");
    ck2.setSecure(false);
  */
    Response.addCookie(&ck2);
  
    ck2.setName("cookie name");
    ck2.setPath("/");
    ck2.setValue("cookie value");
    Response.addCookie(&ck2);
    Response.begin();
  
    printf("Cookie: name=testCookie, value=CookieValue   has been added<br>\n");
    printf("Cookie: name=testCookie2, value=CookieValue2 has been added<br>\n");
    printf("Cookie: name=cookie name, value=cookie value has been added\n");
  
    Response.end();
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.