- 论坛徽章:
- 0
|
代码如下,访问redirectory.cgi的时候,设置cookie,跳转到index.cgi上,能打印出cookie,
但是,关掉index.cgi网页,重新打开index.cgi,不能打印cookie,也就是用户端cookie没有写到磁盘中,请问怎么解决呀?
int main(int argc, char** argv)
{
if (!strcmp(basename(argv[0]), "redirectory.cgi"))
{
printf("Location: ../cgi-bin/auth.cgi\r\n");
printf("Set-Cookie: id=123123; path=/; exprires=Thu, 17-Jul-2009 05:11:33 GMT;\r\n\r\n");
return 0;
}
if (!strcmp(basename(argv[0]), "index.cgi"))
{
char *cookie = getenv("HTTP_COOKIE");
if (cookie != NULL)
{
printf("Content-type: text/html\r\n\r\n");
printf("cookie=%s\n", cookie);
return 0;
}
printf("Content-type: text/html\r\n\r\n");
printf("not have cookie");
return 0;
}
return 0;
} |
|