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;
}

posted on 2010-05-17 17:01  风乔  阅读(558)  评论(0编辑  收藏  举报

导航