是否可以使用 Modernizr 检查 Cookie 是否已启用?
我正在研究如何检查浏览器中是否启用了 cookie,我找到了很多答案,我什至测试了一些答案,但之后我的一个朋友建议我使用 Modernizr 为此。
我开始搜索,发现很多与 CSS3 和 HTML5 相关的东西,但我不想要那样,我只是想知道是否有可能检查Modernizr是否启用了cookie?
I was researching about how to check if the cookies are enabled in a browser and i found a lot of answer, i even tested a few ones, but after that a friend of mine suggest me to use Modernizr for that.
I started to search about that and i found a lot of stuff related with CSS3 and HTML5, but i don't want that, i just wanna know if is it possible to check that cookies are enabled or not with Modernizr?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
检查这个网址,希望它有帮助:
https://github.com/Modernizr/Modernizr/commit/33f00fbbeb12e92bf24711ea386e722cce6f60cc
check this url, hope it's helpful :
https://github.com/Modernizr/Modernizr/commit/33f00fbbeb12e92bf24711ea386e722cce6f60cc
下面的代码是从 http://sveinbjorn.org/cookiecheck 复制的。
Below code is copied from http://sveinbjorn.org/cookiecheck.
这个问题的直接答案是“是的!”它内置于
示例代码中:
您还可以使用 css 类
.cookies
或.no-cookies
来显示/隐藏面板,告诉用户他们需要启用 cookie。(这个
.cookies
类由 Modernizr 添加到标记中)。
注意:如果您正在创建 Modernizr 的自定义版本,则
cookies
选项当前“隐藏”在“非核心检测”部分下。A direct answer to the question is 'Yes!' and it is built in
Example code:
You can also use the css class
.cookies
or.no-cookies
to show/hide a panel telling the user they need cookies enabled.(This
.cookies
class is added to<body>
tag by Modernizr).Note: If you are creating a custom build of Modernizr the
cookies
option is currently 'hidden' under the 'Non-core detects' section.PHP
HTML/PHP 的另一种方式:
PHP - cookcheck.php:
Another way with PHP
HTML/PHP:
PHP - cookcheck.php: