日期:2014-05-19  浏览次数:20424 次

Cookie不写入怎么办呢?
我是新手,我写了一个登陆然后记住Cookie的例子,现在问题是Cookie不知道为什么没显示,浏览器应该没问题,我都换了好几个浏览器了
HttpCookie   mycookie   =   new   HttpCookie( "userName ");
mycookie.Value   =   this.txtName.Text;
mycookie.Expires   =   DateTime.Now.AddDays(1);
Response.Cookies.Add(mycookie);
Response.Redirect( "Index.htm ");

请大家帮忙看看是哪里的问题this.txtName.Text;里面有值

------解决方案--------------------
HttpCookie mycookie = new HttpCookie( "userName "); mycookie[ "a "] = this.txtName.Text; mycookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(mycookie);
------解决方案--------------------
跟Session用法一样的!
------解决方案--------------------
那个页面都还没有回发你的重定向了啊,我想应该是这个问题吧
------解决方案--------------------
HttpCookie objCookie;
objCookie = new HttpCookie( txtCookieName.Text, txtCookieValue.Text );
Response.Cookies.Add( objCookie );
Response.Redirect( "Index.htm ");
------解决方案--------------------
那个页面都还没有回发你的重定向了啊,我想应该是这个问题吧
------------------
我同意这个观点
------解决方案--------------------
我现在也遇到跟楼主一样的问题。请问一下楼主知道了吗?
顺便帮你顶一下啊

知道能够告诉小弟一下啊。Msn:mark3798@homail.com QQ:57766476
------解决方案--------------------
HttpCookie mycookie = new HttpCookie( "userName ");
mycookie.Value = this.txtName.Text;

HttpCookie mycookie = new HttpCookie( "userName ");
mycookie[ "a "] = this.txtName.Text;
对比就知道了
你给mycookie集赋值?
mycookie[ "a "] = this.txtName.Text;
这个是给mycookie集里的[ "a "]赋值
------解决方案--------------------
LZ多看些资料