我在登陆页面设置了cookie :
HttpCookie acookie = new HttpCookie("last_");
acookie.Value = UIN;
acookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(acookie);UNI是我前面定义的字符串然后登陆后其他页面访问cookie :
if (Request.Cookies["last_"] != null)
{
string userId = Request.Cookies["last_"].Value;
string[] lstParm = userId.Split('|');
string role = lstParm[4].ToString();
Set_Role(role);
}我在VS2005里面直接调试没问题, 能够读取,但是 把网站一放上服务器 为什么就读不出了呢 还需要设置什么嘛?
HttpCookie acookie = new HttpCookie("last_");
acookie.Value = UIN;
acookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(acookie);UNI是我前面定义的字符串然后登陆后其他页面访问cookie :
if (Request.Cookies["last_"] != null)
{
string userId = Request.Cookies["last_"].Value;
string[] lstParm = userId.Split('|');
string role = lstParm[4].ToString();
Set_Role(role);
}我在VS2005里面直接调试没问题, 能够读取,但是 把网站一放上服务器 为什么就读不出了呢 还需要设置什么嘛?
解决方案 »
- Dropdownlist 的问题
- 获得文件
- 打开rational rose2003的.mdl文件不成功,显示resolving reference 81%就停止了
- 大家帮忙解决一下????????
- Asp.net中的用户控件之间的事件调用(C#)
- 困绕了我好几天的treeview滚动条问题
- 请问怎么实现这样的表格形式?
- 在调试水晶报表时,出错。急急
- 第三次在线高分征集树型菜单无法显示的答案,已经难倒不少英雄了,搞定给400分,搞不定就要下岗了!各路高手快来救命,别让我对.NET失望
- 急!!!!在DataGrid中怎么加复选框?
- 我的vs2010程序打印时报错,请问是何原因?紧急
- 消除重复项的时候提示 text,ntext,image类型的数据 不能进行比较
不知道是不是iis的问题,可能有什么别设置,
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["last_"] != null)
{
string userId = Request.Cookies["last_"].Value;
Response.Write("OK");
this.Panel1.Visible = false;
}
} protected void Button1_Click(object sender, EventArgs e)
{
HttpCookie acookie = new HttpCookie("last_");
acookie.Value = this.TextBox1.Text;
acookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(acookie);
Response.Redirect("Default.aspx");
}
我把赋值方式 改成 Response.Cookies["last_"].Value = UIN; 读取代码不变 就可以读出了。
具体原因现在还不知道