/* CGI program that simply sets a cookie */ #include #include /* for getenv */ #include #include char *http_header = "content-type: text/html\r\n\r\n"; int main( ) { char *cookies; char *ptr; /* set a cookie */ printf("Set-cookie: favorite=chocolatechip;\r\n"); printf("%s",http_header); /* now print out all the cookies we got */ cookies = getenv("HTTP_COOKIE"); printf("Cookies Are Great\n"); printf("\n"); printf("\n"); printf("

Here are your cookies:


\n"); printf("
    \n"); if (cookies) { ptr = strtok(cookies,";"); while (ptr) { printf("
  • %s\n",ptr); ptr = strtok(NULL,";"); } } printf("
\n"); return(0); }