DBMNG数据库管理与应用

书籍是全世界的营养品。生活里没有书籍,就好像没有阳光;智慧里没有书籍,就好像鸟儿没有翅膀。
当前位置:首页 > 经验分享 > WEB

asp.net c# cookie跨域共享操作

/* HttpCookie cookie = new HttpCookie("MyCook");//初使化并设置Cookie的名称
            cookie.Domain = "test.com";
            DateTime dt = DateTime.Now;
            TimeSpan ts = new TimeSpan(0, 0, 1, 0, 0);//过期时间为1分钟
            //cookie.Expires = dt.Add(ts);//设置过期时间
            cookie.Values.Add("userid", "userid_value");
            cookie.Values.Add("userid2", "userid2_value2");
            Response.AppendCookie(cookie);
            //输出该Cookie的所有内容
            Response.Write(cookie.Value);//输出为:userid=userid_value&userid2=userid2_value2 
            Response.Write("<br/>----------------------------<br/>");//输出为:userid=userid_value&userid2=userid2_value2 
            // HttpCookie cokie = new HttpCookie("MyCook");//初使化
            if (Request.Cookies["MyCook"] != null)
            {
                //Response.Write("Cookie中键值为userid的值:" + Request.Cookies["MyCook"]["userid"]);//整行
                //Response.Write("Cookie中键值为userid2的值" + Request.Cookies["MyCook"]["userid2"]);
                Response.Write(Request.Cookies["MyCook"].Value);//输出全部的值
            }*/

            //HttpCookie cookie = new HttpCookie("uid", "12345600001");
            //cookie.Domain = "test.com";
            //cookie.Path = "/";
            //cookie.Expires = DateTime.Now.AddMinutes(10000);
            //Response.Cookies.Add(cookie);

            //Response.ContentType = "text/plain";
            //Response.AddHeader("P3P", "CP=CAO PSA OUR");
            //Response.Write("设置成功");
            //Response.Write("<br/>----------------------------<br/>");//输出为:userid=userid_value&userid2=userid2_value2 
            //Response.Write(cookie.Value);//输出为:userid=userid_value&userid2=userid2_value2 

           /* String cookies = "";

            //遍历cookies
            for (int i = 0; i < HttpContext.Current.Request.Cookies.Count; i++)
            {

                cookies += HttpContext.Current.Request.Cookies.Keys[i] + ":" + HttpContext.Current.Request.Cookies[i].Value.ToString() + "<br>";
                //Response.Write(HttpContext.Current.Request.Cookies.Keys[i] + ":" + HttpContext.Current.Request.Cookies[i].Value.ToString() + "<br>");
               

            }
            p1.InnerHtml = cookies;*/
本站文章内容,部分来自于互联网,若侵犯了您的权益,请致邮件chuanghui423#sohu.com(请将#换为@)联系,我们会尽快核实后删除。
Copyright © 2006-2023 DBMNG.COM All Rights Reserved. Powered by DEVSOARTECH            豫ICP备11002312号-2

豫公网安备 41010502002439号