选择偏好_网站如何记住您的偏好(以及关于Cookie的选择)?

news/2024/5/9 19:34:16/文章来源:https://blog.csdn.net/culunyi0802/article/details/108839556
选择偏好

选择偏好

how-does-a-website-remember-your-preferences-for-it-00

How do websites remember your preferences for them (or desire for none), and what about the touchy subject of cookies themselves? Today’s SuperUser Q&A post seeks to shed some light on how cookies work and the information they store for a confused reader.

网站如何记起您对它们的喜好(或无所求),以及cookie本身的敏感主题如何? 今天的SuperUser Q&A帖子旨在阐明Cookie的工作方式以及它们为困惑的读者存储的信息。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

Photo courtesy of Pedro Vezini (Flickr).

照片由Pedro Vezini(Flickr)提供 。

问题 (The Question)

SuperUser reader Ruud Lenders wants to know more about how preferences and cookies for websites work:

超级用户读者Ruud Lenders想了解有关网站首选项和cookie的工作方式的更多信息:

A pop-up displayed on a website that I visited and asked me if I would allow the website to store preferences in cookies. By accident, I chose no. Refreshing the page does not bring the pop-up back. Is there a way to get this kind of pop-up back without clearing the history and cookies?

我访问过的网站上显示一个弹出窗口,并询问我是否允许该网站将首选项存储在cookie中。 偶然,我选择了不。 刷新页面不会使弹出窗口返回。 有没有办法在不清除历史记录和Cookie的情况下恢复这种弹出式窗口?

This also got me to thinking. How can a website remember if it is allowed to store cookies? By storing it in a cookie?

这也让我思考。 网站如何记住是否允许其存储Cookie? 通过将其存储在cookie中?

How does a website remember your preferences for it overall and about your choices regarding cookies in general?

网站如何记起您对网站的总体偏好以及关于Cookie的一般选择?

答案 (The Answer)

SuperUser contributor bvukelic has the answer for us:

超级用户贡献者bvukelic为我们提供了答案:

They asked you if you would like to store preferences in cookies, not if you would like them to set cookies in general. So if I were writing support for this feature, I would set a separate cookie (nopref) and check whether or not the user has this cookie. There is a good chance you will find such a cookie for that website, which you can clear without removing other cookies or history.

他们问您是否要将首选项存储在cookie中,而不是是否希望他们通常设置cookie。 因此,如果要编写对此功能的支持,我将设置一个单独的cookie( nopref ),并检查用户是否具有此cookie。 您很有可能会在该网站上找到这样的cookie,您可以在不删除其他cookie或历史记录的情况下清除它。

Inspecting Cookies Set for a Particular Page

检查特定页面的Cookie集

In Firefox, you can list cookies for a particular web page by right-clicking a blank part of the page, then selecting the View Page Info option. You will find a View Cookies button in the Security Tab. In Chrome, you have the same View Page Info option which opens a dialog that hangs from the address bar. A link near the top will take you to a listing of cookies. I assume similar features can be found in other browsers.

在Firefox中,您可以通过右键单击页面的空白部分,然后选择“ 查看页面信息”选项来列出特定网页的Cookie。 您将在“ 安全性”选项卡中找到“ 查看Cookies”按钮。 在Chrome浏览器中,您具有相同的“ 查看页面信息”选项,该选项可打开一个从地址栏挂起的对话框。 顶部附近的链接将带您进入Cookie列表。 我假设可以在其他浏览器中找到类似的功能。

Discovering if a Website Sets a Cookie

发现网站是否设置Cookie

Here is one way that you can discover what the website is doing. Visit the website in Incognito Mode. Open the Developer Tools and switch to the Network Tab. Then check to see what activity is occurring in the background as you decline having the site track you with cookies. Specifically, look for response headers and see if there are any Set-Cookie headers in there. Then try deleting cookies mentioned in the header to see if that makes any difference.

这是您发现网站正在做什么的一种方法。 以隐身模式访问该网站。 打开开发人员工具,然后切换到“ 网络”选项卡 。 然后检查一下,当您拒绝让网站使用Cookie跟踪您时,后台会发生什么活动。 具体来说,查找响应标头,然后查看其中是否有Set-Cookie标头。 然后尝试删除标题中提到的cookie,以查看是否有任何区别。

About localStorage

关于localStorage

Since another poster has mentioned localStorage (in-browser database), I will comment on this as well. I think it will be very rare that a website uses localStorage for this purpose as localStorage data is not accessible to the server unless there is JavaScript code that sends the data back to the server. If you wish to check the contents of localStorage, the fastest way is to open the Developer Tools in your browser, go to the (JavaScript) Console Tab, and type localStorage. This should give you an output that looks something like:

由于另一个发布者提到了localStorage(浏览器内数据库),因此我也会对此发表评论。 我认为网站很少使用localStorage来实现此目的,因为除非有JavaScript代码将数据发送回服务器,否则服务器无法访问localStorage数据。 如果要检查localStorage的内容,最快的方法是在浏览器中打开开发人员工具 ,转到(JavaScript)控制台选项卡 ,然后键入localStorage。 这应该为您提供如下输出:

  • Storage { someKey: “value”, length: 1 }

    存储{someKey:“值”,长度:1}

The someKey identifies the value set by JavaScript on the web page you are on. If you believe someKey does something relevant, you can try removing it by running the following:

someKey标识您所在网页上JavaScript设置的值。 如果您相信someKey可以做一些相关的事情,可以尝试通过运行以下命令将其删除:

  • localstorage.removeItem(‘someKey’);

    localstorage.removeItem('someKey');

This removes the data under someKey from localStorage, and reloading the web page may restore it to factory settings. If you are not sure the particular key is set by the cookie notification functionality, you may open the web page in Incognito Mode and list the contents of localStorage before interacting with the web page.

这将从localStorage中删除someKey下的数据,并且重新加载网页可能会将其恢复为出厂设置。 如果不确定cookie通知功能是否设置了特定键,则可以在与网页交互之前以隐身模式打开网页并列出localStorage的内容。

Again, I doubt many websites use localStorage for this purpose.

同样,我怀疑许多网站为此目的使用localStorage。



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程 。

翻译自: https://www.howtogeek.com/196040/how-does-a-website-remember-your-preferences-for-it-and-choices-regarding-cookies/

选择偏好

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_732809.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

更改服务器网站安装目录权限,Apache Wind2003 配置网站目录权限小结

Apache Wind2003 配置网站目录权限小结更新时间:2009年09月05日 22:32:03 作者:Apache Windows 2003 配置网站目录权限小结非常简单的权限设置,就是访问网站时会弹出用户名和密码,通过身份验证后可以正常浏览,如下图…

询问HTG:在网站中搜索,Google Play替代品以及双重引导入门

Once a week we round up some of the reader letters we’ve answered and share the advice with everyone. This week we’re looking at how to search within web sites, downloading apps from places other than Google Play, and getting started with dual booting op…

tcp流式传输_收听互联网广播以及下载和流式传输免费音乐的最佳网站

tcp流式传输When was the last time you listened to over-the-air FM radio? There are so many options on the internet for listening to thousands of different radio stations in many different genres and for downloading a lot of music for free. 您上次收听无线调…

rss阅读器_赶上您喜欢的网站的最佳免费RSS阅读器

rss阅读器RSS stands for “Really Simple Syndication” or “Rich Site Summary.” It’s a document specification that allows you to easily collect and organize web-based news and information from websites. RSS reader applications allow you to follow your fav…

win 8 metro交互_将您喜欢的网站固定到Windows 8中的Metro Start屏幕

win 8 metro交互It’s easy to pin apps and folders to the Metro Start screen in Windows 8. What about your favorite websites? Windows 7 allows you to pin websites to the Taskbar. It’s also easy to pin your favorite websites to the Windows 8 Metro Start sc…

谷歌浏览器怎么阻止更新_如何在谷歌浏览器中阻止网站

谷歌浏览器怎么阻止更新Do you find yourself accessing Facebook, Twitter, or other distracting websites when you really should be doing something else instead? Block that website in Google Chrome. Other solutions will let you block websites for children at …

不识别字体_设计师最常用的几个字体网站,解决你苦寻字体烦恼!

大家好,又到了和大家一起学习交流的时间了,今天我们给大家推荐几个设计师经常用到的字体网站。这些字体网站是我经常使用到的,很方便,也很好用,什么样的字体都可以找的到。1、 求字体直通车:http://www.qiu…

java学习就去这56个网站论坛(附各种java学习公众号)

2019独角兽企业重金招聘Python工程师标准>>> java学习不是一蹴而就的,重在平时的积累和阅读,下面这些java学习的主流论坛,是洒家花了一周时间“搜刮”过来的,基本包括了所有java学习的最优质网站,所以&…

使用sql服务器发送贺卡_发送免费电子贺卡的最佳网站

使用sql服务器发送贺卡If you’re looking to send eCards to your friends and family, there are hundreds of websites from which to choose. We’ve done the hard work and scouted the best sites with a widest range of eCards for birthdays, holidays, and other sp…

怎么把网页源码家入hexo博客_利用 Github+Hexo 搭建个人博客网站

↑↑↑点击上方“蓝字”,关注“极客猴”如果你喜欢极客猴,可以把我置顶或加为星标题图:by watercolor.illustrations from Instagram阅读文本大概需要 3 分钟。我之前写过一篇文章《利用GithubJeklly搭建个人博客网站》,利用 Gith…

没有为网站或应用程序启用相应的 mime 映射。_六安营销网站搭建注意事项,仪表网站制作,服务为先...

首页 > 新闻中心发布时间:2020-11-08 06:24:47 导读:北京佐助信息科技有限公司为您提供六安营销网站搭建注意事项,仪表网站制作的相关知识与详情: 很自然很难克服这种技术心理障碍 如果发生这种情况,恭喜您,网站可能…

数据量大的sql怎么做优化_初期网站怎么优化?优化设计方案怎么做?才能快速上首页...

原标题:初期网站怎么优化?优化设计方案怎么做?才能快速上首页对于大多数西安网站建设公司来说,企业站的SEO优化比必不可少的,我在这里要强调的是,无论是新站还是老站,在做SEO优化之前&#xff0…

vue转静态页面_10 大静态网站生成工具 | Linux 中国

导读:在寻找部署静态网页的方法吗?这几个开源的静态网站生成工具可以帮你迅速部署界面优美、功能强大的静态网站,无需掌握复杂的 HTML 和 CSS 技能。本文字数:3396,阅读时长大约:5分钟https://linux.cn/art…

判断页面是否有未提交的内容_多域名指向同一网站,301重定向怎么做?为什么要设置404错误页面?...

一、404错误页面404错误:网页不存在或不可访问则URL地址为404;增加用户跳出率,增加搜索引擎蜘蛛丢失率。404错误页面作用:减少用户跳出率,减少搜索引擎蜘蛛丢失率。制作404页面要求:必须有返回网站的链接&a…

判断分辨网站是否伪静态的方法

所有seoer都知道网站的优化最好是静态网页,但是有些时候静态网 hakuci 标签: 伪静态页是无法满足建站需求的,所以伪静态就出现了,而我们浏览其他的网站,看他是不是动态都是看他的网址有没有?之类的符号,而要判断伪静态…

.net core3.0上传文件出现404_论404错误页面对SEO优化的影响

什么是404错误页面:告诉浏览者其所请求的页面不存在或链接错误,同时引导用户使用网站其他页面而不是关闭窗口离开。产生404错误页面原因:1.网页URL生成规则改变。2.网页文件更名或移动位置。3.导入链接拼写错误。注:以上3个为常见…

会员直推奖php程序_网站优化篇:网站程序的选择

在搭建时,我们要选择什么样的程序呢?这个是有讲究的,建议大家使用自己最熟悉的程序,因为不熟悉,我们就要去学习程序的使用,一个程序要几天才能够操作,1天,2天,或又者是7天…

Apache服务部署静态网站

网站服务程序IIS应用于Windows系统中Nginx(特点:系统资源消耗低且并发能力强)Apache可以应用于Linux、Unix、Windows系统中 Apache服务程序部署第1步:把光盘设备中的系统镜像挂载到/media/cdrom目录。第2步:使用Vim文本…

网站安装打包 软件环境检测与安装[二] 下

2019独角兽企业重金招聘Python工程师标准>>> 这一节主要说安装! 1。操作系统 这个应该不用了,没系统也没法运行了! 2。IIS安装 这个是重点,最后面介绍! 3。framework安装 这个也不用了,工具安装…