赞助连接

赞助连接

阅 读 文 章

用cgic设置与读取cookie的问题

[来源:网上转载 (http://bbs.chinaunix.net) | 作者:网友() | 时间:2007-06-24 | 浏览: 人次 ]

引用cgic中cookie写如下程序:

test1:
#include <stdio.h>
#include "cgic.h"
#include <string.h>
#include <stdlib.h>
#if 1
#define SERVER_NAME cgiServerName
#endif
void CookieSet();
int cgiMain()
{
         
        CookieSet();
        cgiHeaderContentType("text/html");

         printf("<form name=\"form1\" method=\"post\" action=\"test2\">");
         printf("<input name=cname type=text  size=15 maxlength=8>");
         printf("<br>");
         printf("<input name=cvalue type=text  size=15 maxlength=8>");
         printf("<input name=\"Submit\" type=\"submit\" class=\"button\" value=\"提交\">");
         printf("</form>");
       
        return 0;
}

void CookieSet()
{
        char cname[1024];
        char cvalue[1024];
        /* Must set cookies BEFORE calling cgiHeaderContentType */
        cgiFormString("cname", cname, sizeof(cname));       
        cgiFormString("cvalue", cvalue, sizeof(cvalue));
        //printf("strlen(cname)=%d\n",strlen(cname));       
        if (strlen(cname)) {
                /* Cookie lives for one day (or until browser chooses
                        to get rid of it, which may be immediately),
                        and applies only to this script on this site. */       
                cgiHeaderCookieSetString(cname, cvalue,
                        86400, cgiScriptName, SERVER_NAME);
        }
}


test2:

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

void Cookies();
int cgiMain()
{
       
        cgiHeaderContentType("text/html");
       
        Cookies();
        printf("<a href=http://bbs.chinaunix.net/test3>111</a>");
TAG标签 : 问题 读取 设置 cname cvalue arrayStep fprintf cgiOut

最新评论 共有2位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表
网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.newhtm.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.