CGI C 设置 读取 cookies

#include <stdio.h>
#include "cgic.h "
#include <string.h>
#include <stdlib.h>
test1.cgi
int cgiMain()
{
char username[25]= "uuuu ";
char pass[25] = "123 ";
//printf( "Set-Cookie:username=%s;Set-Cookie:password=%s\n ",username,pass);

printf( "Set-Cookie: username=%s; path=/\r\n ", username);
printf( "Set-Cookie: password=%s; path=/\r\n ", pass);

cgiHeaderContentType( "text/html ");

printf( " <a href=test2> 1111 </a> ");
return 0;
}


test2
#include <stdio.h>
#include "cgic.h "
#include <string.h>
#include <stdlib.h>

int cgiMain()
{

cgiHeaderContentType( "text/html ");
printf( "Cookie:%s\n ",getenv( "HTTP-COOKIE "));
return 0;
}

你可能感兴趣的:(Cookies)