简体   繁体   English

检查浏览器Cookie是否已禁用

[英]Check browser cookie disabled

We are using an Http Module. 我们正在使用Http模块。 In the http module we are setting a cookie. 在http模块中,我们设置了一个cookie。 After that in the page we are trying to take the value from cookie. 之后,在页面中,我们尝试从cookie中获取值。

So when we are requesting a page, first the code inside http module will execute and it will set the cookie and then the value can be taken from cookie in the page load of the page. 因此,当我们请求页面时,首先将执行http模块内的代码,它将设置cookie,然后可以从页面页面加载中的cookie中获取值。

But while debugging the code in Visual studio, we found that if browser cookie is disabled , then in the httpModule it will try to set the cookie and after that in the page load if we check the request object, it is showing the cookie set from the httpModule. 但是在Visual Studio中调试代码时,我们发现如果禁用了浏览器cookie ,则它将在httpModule中尝试设置cookie,然后在页面加载中如果我们检查请求对象,它将显示从httpModule。

Is this a correct behavior? 这是正确的行为吗? I want to know whether cookie is disabled in this case. 我想知道在这种情况下是否禁用cookie。 If it is diabled i want to take another value from db. 如果它是禁用的,我想从数据库中获取另一个值。 But it always showing the value in cookie. 但是它总是显示cookie中的值。

Can anyone please suggest a method to get whether cookie is disabled or not. 任何人都可以提出一种获取Cookie是否被禁用的方法的建议。

We are using the httpModule in an Umbraco site. 我们正在Umbraco网站中使用httpModule。

I would write a cookie and then do a redirect to check if that cookie exists if it does then you know cookies are enabled if not then cookies are not enabled. 我会编写一个cookie,然后进行重定向以检查该cookie是否存在(如果存在),然后您知道是否启用了cookie,否则就没有启用cookie。 Here is a good example. 这是一个很好的例子。

http://www.primaryobjects.com/CMS/Article54.aspx http://www.primaryobjects.com/CMS/Article54.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM