COOKIE API

1. wbCreateCookie

wbCreateCookie creates a new cookie.

Creates a new cookie using the initial name and value. See the Netscape Cookie Specification and RFC 2019 for rules on valid names and values.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    cookie_t* wbCreateCookie(WBSVCINFO *rqst, char *name, char *value)
  • Return value

    wbCreateCookie() returns a pointer to the created cookie.

  • Example

    <createcookie.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVICE
     test           SVRNAME = createcookie
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i createcookie.m
    2. Create a service table.

      $wsgst
    3. Create a source file. The following is an example WBAPI program that processes a request, named createcookie.c.

       #include <stdio.h>
       #include <string.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
      
       test(WBSVCINFO *rqst) {
              char *name, *value;
              cookie_t *cookie;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              name = wbCookieGetName(rqst, cookie);
              wbPrint(rqst, "cookie name = %s\n<br>", name);
              value = wbCookieGetValue(rqst, cookie);
              wbPrint(rqst, "cookie value = %s\n<br>", value);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c createcookie
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

2. wbGetCookie

wbGetCookie returns a specific cookie from the cookies sent by the browser.

This function returns a pointer to the cookie that matches the specified name among the cookies included in the request from the browser. If no matching cookie is found, it returns NULL.

The name parameter allows the user to specify the particular cookie to retrive from the available cookies.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    cookie_t *wbGetCookie(WBSVCINFO *rqst, char *name)
  • Return value

    Returns a pointer to the cookie that matches the specified name among the cookies included in the request from the browser. If no matching cookie is found, NULL is returned.

  • Example

    <getcookie.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     getcookie      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = getcookie
     test2           SVRNAME = getcookie
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i getcookie.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named getcookie.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst)
       {
              cookie_t *cookie;
              int ver;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              ver = wbPutCookie(rqst, cookie);
              wbPrint(rqst, "<html><body>\n");
              wbPrint(rqst, "<form method=post action=/svct/test2>\n");
              wbPrint(rqst, "wbGetCookie test \n<br>");
              wbPrint(rqst, "create cookie \n<br>");
              wbPrint(rqst, "<input type=submit value=submit>");
              wbPrint(rqst, "</form>");
              wbPrint(rqst, "</body></html>\n");
              wbReturn(rqst, WBSUCCESS);
       }
      
       test2(WBSVCINFO *rqst) {
              cookie_t *cookie;
              char *name, *value;
              cookie = wbGetCookie(rqst, "name");
              wbPrint(rqst, "<html><body>\n");
              wbPrint(rqst, "wbGetCookie test \n<br>");
              name = wbCookieGetName(rqst, cookie);
              wbPrint(rqst, "cookie name = %s\n<br>", name);
              value = wbCookieGetValue(rqst, cookie);
              wbPrint(rqst, "cookie value = %s\n<br>", value);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c getcookie
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

      Clicking the [Submit] button calls the wbapi service test2 and displays the result of wbGetCookie.

      image

  • Related functions

    wbPutCookie()

3. wbPutCookie

wbPutCookie appends a specified cookie to the response. Additional cookies can be appended by calling wbPutCookie() multiple times. Since cookies are sent through HTTP headers, they must be appended to the response before any content is sent.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbPutCookie(WBSVCINFO *rqst, cookie_t *cookie)
  • Return value

    If successful, wbPutCookie() returns 1. If an error occurs, it returns 0.

  • Example

    <putcookie.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     putcookie      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = putcookie
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i putcookie.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named putcookie.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst)
       {
              cookie_t *cookie;
       cookie_t *cookie1;
              int ver;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              ver = wbPutCookie(rqst, cookie);
              cookie1 = wbCreateCookie(rqst, "id", "xxxxxxx");
              ver = wbPutCookie(rqst, cookie1);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c putcookie
    5. The following is an example of the resulting output.

      When requesting WBAPI service with Telent, the following result is produced.

       HTTP/1.1 200 OK
       Date: Thu, 01 Nov 2001 01:47:04 GMT
       Server: WebtoB/3.0
       Set-Cookie: name=tmaxsoft
       Set-Cookie: id=xxxxxxx
       Content-Type: text/html
       Content-Length:       0
  • Related functions

    wbGetCookie()

4. wbCookieGetDomain

wbCookieGetDomain returns the domain associated with the specified cookie. This domain specifies the servers for which the cookie is valid. By default, cookies are sent to the host that set them, but this behavior can be overridden by specifying a domain name pattern. The pattern must begin with a dot and include at least two dots. For further details on domain patterns, refer to RFC 2109.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char * wbCookieGetDomain(WBSVCINFO *rqst, cookie_t *cookie)
  • Return value

    wbCookieGetDomain() returns the pattern specified for the cookie. If no domain is specified, it returns NULL.

  • Example

    <getdomain.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     getdomain      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = getdomain
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i getdomain.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named getdomain.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
      
       test(WBSVCINFO *rqst) {
              cookie_t *cookie;
              int ver;
              char *domain;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              wbCookieSetDomain(rqst, cookie, ".tmax.co.kr");
              ver = wbPutCookie(rqst, cookie);
              domain = wbCookieGetDomain(rqst, cookie);
              wbPrint(rqst, "<h2>Domain = %s</h2>", domain);
              wbCookieGetDomain(rqst, cookie);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c getdomain
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieGetName(), wbCookieGetPath(), wbCookieGetValue(), wbCookieGetVersion()

5. wbCookieGetName

wbCookieGetName returns the name of the specified cookie. Every cookie consists of a valid name and value, and wbCookieGetName() can retrieve the cookie’s name. For more information about valid cookie names, see RFC 2109.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char * wbCookieGetName(WBSVCINFO *rqst, cookie_t *cookie)
  • Return value

    wbCookieGetName() returns the name of the specified cookie. If no valid cookie is found, it returns NULL.

  • Example

    <getname.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html            SVGNAME = htmlg, MinProc = 1, MaxProc =2
     getname         SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test            SVRNAME = getname
    
    *URI
     wbapi           Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm             MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i getname.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named getname.c.

       #include <stdio.h>
       #include <string.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst)
       {
              char *name, *value;
              cookie_t *cookie;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              name = wbCookieGetName(rqst, cookie);
              wbPrint(rqst, "cookie name = %s\n<br>", name);
              value = wbCookieGetValue(rqst, cookie);
              wbPrint(rqst, "cookie value = %s\n<br>", value);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c getname
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieGetDomain(), wbCookieGetPath(), wbCookieGetValue(), wbCookieGetVersion()

6. wbCookieGetPath

wbCookieGetPath returns the path associated with the specified cookie. This path represents the part of the URI where the cookie was initially set. The cookie will be sent with requests to the page that created it, as well as to all pages within the same directory and any subdirectories.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char* wbCookieGetPath(WBSVCINFO *rqst, cookie_t *cookie)
  • Return value

    wbCookieGetPath() returns the path of the cookie. If no path is specified, it returns NULL.

  • Example

    <path.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     path           SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = path
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i path.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named path.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst)
       {
              cookie_t *cookie;
              char *path;
              int ver;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              wbCookieSetPath(rqst, cookie,"/user2/HanInho/webtob" );
              ver = wbPutCookie(rqst, cookie);
              path = wbCookieGetPath(rqst, cookie);
              wbPrint(rqst, "<h2>Path = %s</h2>", path);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c path
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieGetName(), wbCookieGetDomain(), wbCookieGetValue(), wbCookieGetVersion()

7. wbCookieGetValue

wbCookieGetValue returns the stored value of a specified cookie. When a cookie is created, it is assigned a name and a value. wbCookieGetValue() retrieves this value associated with the specified cookie name.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char* wbCookieGetValue(WBSVCINFO *rqst, cookie_t *cookie)
  • Return value

    wbCookieGetValue() returns the value of the cookie.

  • Example

    <value.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     value          SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = value
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i value.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named value.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst)
       {
              cookie_t *cookie;
              int ver;
              char *value;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              value = wbCookieGetValue(rqst, cookie);
              wbPrint(rqst, "<h2>old value = %s</h2>", value);
              ver = wbPutCookie(rqst, cookie);
              wbCookieSetValue(rqst, cookie,"webtob");
              value = wbCookieGetValue(rqst, cookie);
              wbPrint(rqst, "<h2>new value = %s</h2>", value);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c value
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieGetName(), wbCookieGetPath(), wbCookieGetDomain(), wbCookieGetVersion()

8. wbCookieGetVersion

wbCookieGetVersion returns the version of the specified cookie.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieGetVersion(WBSVCINFO *rqst, cookie_t *cookie)
  • Return value

    wbCookieGetVersion() returns the version of the cookie. If no version is set, it returns the default value of 0.

  • Example

    <version.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     version        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = version
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i version.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named version.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst){
              cookie_t *cookie;
              int ver;
              int version;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              version = wbCookieGetVersion(rqst, cookie);
              wbPrint(rqst, "<h2>old version = %d</h2>", version);
              ver = wbPutCookie(rqst, cookie);
              wbCookieSetVersion(rqst, cookie,1);
              version = wbCookieGetVersion(rqst, cookie);
              wbPrint(rqst, "<h2>new version = %d</h2>", version);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c version
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieGetName(), wbCookieGetPath(), wbCookieGetValue(), wbCookieGetDomain()

9. wbCookieSetComment

wbCookieSetComment sets the comment field of a cookie. The argument comment describes the purpose of the cookie. Web browsers may display this comment string to the user. Note that comments are not supported in version 0 cookies.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieSetComment(WBSVCINFO *rqst, cookie_t *cookie, char *comment)
  • Return value

    If wbCookieSetComment() executes successfully, it returns 1; otherwise, it returns -1.

  • Example

    <comment.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     comment        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = comment
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i comment.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named comment.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
      
       test(WBSVCINFO *rqst)
       {
              cookie_t *cookie;
              int ver;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              ver = wbPutCookie(rqst, cookie);
              wbCookieSetComment(rqst, cookie,"example");
              wbPrint(rqst, "<h2>comment is = %s</h2>", cookie->comment);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c comment
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieSetName(), wbCookieSetPath(), wbCookieSetValue(), wbCookieSetVersion(), wbCookieSetDomain(),wbCookieSetMaxAge(), wbCookieSetSecure()

10. wbCookieSetDomain

wbCookieSetDomain sets a pattern that limits the domain of a cookie. The domain pattern clearly determines which servers the cookie should be sent to. By default, cookies are returned only to the host where they were stored. To set a domain name pattern, the domain name must be overridden. The pattern must start with a dot and contain at least two dots.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieSetComment(WBSVCINFO *rqst, cookie_t *cookie, char *domain)
  • Return value

    If wbCookieSetDomain() executes successfully, it returns 1; otherwise, it returns -1.

  • Example

    <setdomain.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     setdomain      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = setdomain
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i setdomain.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named setdomain.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst)
       {
              cookie_t *cookie;
              int ver;
              char *domain;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              wbCookieSetDomain(rqst, cookie, ".tmax.co.kr");
              ver = wbPutCookie(rqst, cookie);
              domain = wbCookieGetDomain(rqst, cookie);
              wbPrint(rqst, "<h2>Domain = %s</h2>", domain);
              wbCookieGetDomain(rqst, cookie);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c setdomain
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieSetName(), wbCookieSetPath(), wbCookieSetValue(), wbCookieSetVersion(), wbCookieSetComment(), wbCookieSetMaxAge(), wbCookieSetSecure()

11. wbCookieSetMaxAge

wbCookieSetMaxAge sets the maximum age of a cookie in seconds before the cookie expires. A negative value means the cookie should expire as soon as the browser closes. A value of 0 specifies that the browser should immediately delete the cookie. The default value is -1.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieSetMaxAge(WBSVCINFO *rqst, cookie_t *cookie, int maxage)
  • Return value

    If wbCookieSetMaxAge() executes successfully, it returns 1; otherwise, it returns -1.

  • Example

    <maxage.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     maxage         SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = maxage
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i maxage.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named maxage.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
      
       test(WBSVCINFO *rqst) {
              cookie_t *cookie;
              int ver;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              wbCookieSetMaxAge(rqst, cookie,60 );
              ver = wbPutCookie(rqst, cookie);
              wbPrint(rqst, "<h2>Maxage = %d</h2>", cookie->maxage);
                      wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c maxage
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieSetName(), wbCookieSetPath(), wbCookieSetValue(), wbCookieSetVersion(), wbCookieSetDomain(), wbCookieSetComment(), wbCookieSetSecure()

12. wbCookieSetPath

wbCookieSetPath sets the path for the cookie. This is the part of the URI where the cookie should be sent. If you set a cookie to /user/han, the default path will be /user. This path also indicates that the cookie should be sent to /user/aaa or /user/bbb.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieSetPath(WBSVCINFO *rqst, cookie_t *cookie, char *path)
  • Return value

    If wbCookieSetPath() executes successfully, it returns 1; otherwise, it returns -1.

  • Example

    <setpath.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     setpath        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = setpath
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i setpath.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named setpath.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst) {
              cookie_t *cookie;
              char *path;
              int ver;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              wbCookieSetPath(rqst, cookie,"/user2/HanInho/webtob" );
              ver = wbPutCookie(rqst, cookie);
              path = wbCookieGetPath(rqst, cookie);
              wbPrint(rqst, "<h2>Path = %s</h2>", path);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c setpath
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieSetName(), wbCookieSetComment(), wbCookieSetValue(), wbCookieSetVersion(), wbCookieSetDomain(), wbCookieSetMaxAge(), wbCookieSetSecure()

13. wbCookieSetSecure

wbCookieSetSecure sets whether cookies should be transmitted over a secure protocol such as SSL. The default value is 0, which allows cookies to be used even over unsecured protocols.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieSetSecure(WBSVCINFO *rqst, cookie_t *cookie, int secure)
  • Return value

    If wbCookieSetSecure() executes successfully, it returns 1; otherwise, it returns -1.

  • Example

    <secure.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     secure         SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = secure
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i secure.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named secure.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst) {
              cookie_t *cookie;
              int ver, sec;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              wbCookieSetSecure(rqst, cookie,1 );
              ver = wbPutCookie(rqst, cookie);
              wbPrint(rqst, "<h2>Secure = %d</h2>", cookie->secure);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c secure
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieSetName(), wbCookieSetPath(), wbCookieSetValue(), wbCookieSetVersion(), wbCookieSetDomain(), wbCookieSetMaxAge(), wbCookieSetComment()

14. wbCookieSetValue

wbCookieSetValue sets a new value for a cookie. For version 0 cookies, the value must not contain spaces, brackets, parentheses, equal signs, commas, double quotes, slashes, question marks, signs, or semicolons.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieSetValue(WBSVCINFO *rqst, cookie_t *cookie, char *value)
  • Return value

    If wbCookieSetValue() executes successfully, it returns 1; if it fails, it returns -1.

  • Example

    <setvalue.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     setvalue       SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = setvalue
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i setvalue.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named setvalue.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst)
       {
              cookie_t *cookie;
              int ver;
              char *value;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              value = wbCookieGetValue(rqst, cookie);
              wbPrint(rqst, "<h2>old value = %s</h2>", value);
              ver = wbPutCookie(rqst, cookie);
              wbCookieSetValue(rqst, cookie,"webtob");
              value = wbCookieGetValue(rqst, cookie);
              wbPrint(rqst, "<h2>new value = %s</h2>", value);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c setvalue
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieSetName(), wbCookieSetPath(), wbCookieSetComment(), wbCookieSetVersion(), wbCookieSetDomain(), wbCookieSetMaxAge(), wbCookieSetSecure()

15. wbCookieSetVersion

wbCookieSetVersion resets the version of cookie.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbCookieSetVersion(WBSVCINFO *wbsvc, cookie_t *cookie, int version);
  • Return value

    If wbCookieSetVersion() executes successfully, it returns 1. If it fails, it returns 0.

  • Example

    <version.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     version        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = version
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i version.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named version.c.

       #include <stdio.h>
       #include "../usrinc/atmi.h"
       #include "../usrinc/wbapi.h"
       test(WBSVCINFO *rqst) {
              cookie_t *cookie;
              int ver;
              int version;
              cookie = wbCreateCookie(rqst, "name", "tmaxsoft");
              version = wbCookieGetVersion(rqst, cookie);
              wbPrint(rqst, "<h2>old version = %d</h2>", version);
              ver = wbPutCookie(rqst, cookie);
              wbCookieSetVersion(rqst, cookie,1);
              version = wbCookieGetVersion(rqst, cookie);
              wbPrint(rqst, "<h2>new version = %d</h2>", version);
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c version
    5. The following is the screen where the results are printed.

      When you request a WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbCookieGetName(), wbCookieGetPath(), wbCookieGetValue(), wbCookieGetDomain()