asp.net 如何读取当前浏览器中的cookie的所有记录~急~
3个回答
展开全部
其他网站的Cookie是不能获取的,但可以获取本网站的所有Cookie。代码如下:
int n,m = 0;
n = Request.Cookies.Count;
Label1.Text = "目前共定义了" + n.ToString() + "个Cookie";
HttpCookie mycookie;
if (n > 0)
{
Label1.Text += ":";
foreach (string CookieName in Request.Cookies)
{
mycookie = Request.Cookies[CookieName];
Label1.Text += "<br /> Cookie “";
Label1.Text += CookieName + "” 中含有";
m = mycookie.Values.Count;
Label1.Text += m.ToString() + "个Key";
if (m > 0)
{
Label1.Text += ":";
foreach (string s in mycookie.Values)
{
Label1.Text += " “" + s + "”=" + mycookie[s].ToString() + ";";
}
}
}
}
int n,m = 0;
n = Request.Cookies.Count;
Label1.Text = "目前共定义了" + n.ToString() + "个Cookie";
HttpCookie mycookie;
if (n > 0)
{
Label1.Text += ":";
foreach (string CookieName in Request.Cookies)
{
mycookie = Request.Cookies[CookieName];
Label1.Text += "<br /> Cookie “";
Label1.Text += CookieName + "” 中含有";
m = mycookie.Values.Count;
Label1.Text += m.ToString() + "个Key";
if (m > 0)
{
Label1.Text += ":";
foreach (string s in mycookie.Values)
{
Label1.Text += " “" + s + "”=" + mycookie[s].ToString() + ";";
}
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询