网络乞丐

Web开发

.NET中COOKIES跨域解决办法

简单代码如下:———————————————————————————————————
更新cooikes
//如果存在cookie,则更新value属性;否则,new一个cookie。
HttpCookie cookies = Request.Cookies["userName"];
if (cookies == null)
{
cookies = new HttpCookie("userName", this.txtUserName.Text);
cookies.Domain = ".vip8848.cn";
Response.Cookies.Set(cookies);
}
else
{
cookies.Value = this.txtUserName.Text;
cookies.Domain = ".vip8848.cn";
Response.Cookies.Set(cookies);
cookies = new HttpCookie("userName", this.txtUserName.Text);

}
读出COOKIES
HttpCookie cookies = Request.Cookies["userName"];
if (cookies != null)
{

this.TextBox1.Text = cookies.Value;
}
查看所有的COOKIES
HttpCookieCollection cookies;
HttpCookie oneCookie;
cookies = Request.Cookies;
string[] cookieArray = cookies.AllKeys;
for (int i = 0; i < cookieArray.Length; i++)
{

oneCookie = cookies[cookieArray[i]];

Response.Write(oneCookie.Name + " - " + oneCookie.Value);
}
 
阅读更多
文章标签: cookies .net null string
个人分类: ASP.net&amp;C#
上一篇用 MD5 加密数据库中的用户密码
下一篇ASP.NET2.0的缓存控件和地址映射
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭