如何更改cookie的值? [英] How can i change the value of the cookie?

查看:141
本文介绍了如何更改cookie的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在按下LOGOUT按钮时更改cookie的值...

I am trying to change the value of the cookie when the LOGOUT button is pressed like this...

Request.Cookies["LoginInfo"].Value=null;






or

Request.Cookies["LoginInfo"].Value="0";



我无法更改cookie的值...

有什么方法可以随时更改值...

plz help ...


I am unable to change the value of cookie...
is there any way to change the value at any time...
plz help...

推荐答案

关于Cookie的保养和处理 [ ^ ]


你好,



你可以试试像



Hello,

You can try something like

Response.Cookies["LoginInfo"].Value = "0";


也许您需要将cookie的到期时间设置为将来。另外,设置响应,而不是请求:

Perhaps you need to set the expiration of the cookie to be in the future. Also, set the response, not the request:
Response.Cookies["LoginInfo"].Expires = DateTime.Now.AddDays(1);





http://msdn.microsoft.com/en-us /library/ms178194.aspx (ASP.NET Cookies概述)



http://msdn.microsoft.com/en-us/library/ms178194.aspx (ASP.NET Cookies Overview)


这篇关于如何更改cookie的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆