读写cookie [英] Reading and writing cookies
问题描述
在我的ASP.net应用程序中,我使用cookie来保存一些用户数据。因此,我在Signin按钮单击中创建一个新的cookie,并将其添加到Response.Cookies.add,然后是response.redirect(到某个仪表板页面)。调用此重定向时,会触发Application_AuthenticateRequest
事件(在Global.asax.cs中)。在这里,我将从cookie中提取信息(使用Request.Cookies [" CookieName"])并验证用户数据。
In my ASP.net application, I use cookies to hold some user data. So I create a new cookie in Signin button click and add that to Response.Cookies.add followed by response.redirect (to some dashboard page). When this redirect is called, Application_AuthenticateRequest event (in Global.asax.cs ) triggered. Here i will extract the info from cookie (Using Request.Cookies["CookieName"]) and validate the user data.
现在问题是Request.Cookies [" CookieName"]会导致旧cookie而不是Signin.aspx.cs中编写的新cookie。此问题在大约5-10个路径中发生一次并且不一致。任何人都可以帮我这个
Now the issue is Request.Cookies["CookieName"] results old cookie instead of the new one that was written in the Signin.aspx.cs. This issue occurs once in around 5-10 trails and not consistent. Can anyone help me with this
推荐答案
您是否尝试使用 Response.Cookies.Remove删除旧值在添加新的之前?
这篇关于读写cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!