網站如何記住你對它的偏好(以及關於cookies的選擇)?

網站如何記住你對它們的偏好(或者不想要),以及cookies本身的敏感主題呢?今天的超級使用者問答旨在為困惑的讀者解釋cookies的工作原理和它們儲存的資訊。...

網站如何記住你對它的偏好(以及關於cookies的選擇)?

網站如何記住你對它們的偏好(或者不想要),以及cookies本身的敏感主題呢?今天的超級使用者問答旨在為困惑的讀者解釋cookies的工作原理和它們儲存的資訊。

今天的問答環節是由SuperUser提供的,SuperUser是Stack Exchange的一個分支,是一個由社群驅動的問答網站分組。

圖片由Pedro Vezini(Flickr)提供。

問題

超級使用者讀者Ruud Lenders想了解更多關於網站偏好和cookies的工作原理:

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?

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

網站如何記住你對它的總體偏好,以及你對cookies的總體選擇?

答案

超級使用者貢獻者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.

Inspecting Cookies Set for a Particular Page

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.

Discovering if a Website Sets a 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 resp***e 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.

About 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) C***ole Tab, and type localStorage. This should give you an output that looks something like:

  • Storage { someKey: “value”, length: 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:

  • 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.

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


有什麼要補充的解釋嗎?在評論中發出聲音。想從其他精通技術的Stack Exchange使用者那裡瞭解更多答案嗎?在這裡檢視完整的討論主題。

  • 發表於 2021-04-11 07:03
  • 閱讀 ( 54 )
  • 分類:網際網路

你可能感興趣的文章

關於谷歌chrome的新cookies政策,你需要知道的一切

... 然後,cookies將資訊提供給網站運營商。此資訊可提高網站載入速度,管理與裝置相關的崩潰報告,並跟蹤密碼。此外,cookies將搜尋連結到您的Google帳戶,以改進用於提供廣告的預測性建議。 ...

  • 發佈於 2021-03-10 20:45
  • 閲讀 ( 45 )

sonos roam正式釋出,它看起來像一個偉大的行動式揚聲器

您在使用Chrome訪問桌面或**上的網站時遇到問題嗎?你的cookies和快取檔案可能是罪魁禍首。去掉這些檔案,然後看看Chrome的效能是否更好。 ...

  • 發佈於 2021-03-11 11:15
  • 閲讀 ( 44 )

如何清除safari瀏覽歷史和資料

...間都花在網上,你的瀏覽器會記住你訪問和登入過的所有網站。你的瀏覽器儲存資料,使它更容易和更快地回到你經常訪問的網站。 ...

  • 發佈於 2021-03-12 01:08
  • 閲讀 ( 56 )

谷歌chrome常見問題解答

...的主頁?也許一個新的標籤擴充套件或網際網路上最好的網站之一就足夠了。 ...

  • 發佈於 2021-03-12 03:38
  • 閲讀 ( 60 )

5種簡單方法為您選擇最佳手機瀏覽器

... 在那些具有額外功能的網站中,Dolphin就是其中之一。此瀏覽器提供了一個手勢繪製功能,可以快速訪問網站和常用操作。Puffin提供了一個可定製的顯示以及它自己的一套可選的附加元件。Opera Mi...

  • 發佈於 2021-03-17 11:42
  • 閲讀 ( 51 )

23個網站的許可權在谷歌chrome中更改,以便更好地瀏覽

...有一長串你可以切換的許可權嗎?這使您可以更好地控制網站如何與您的裝置互動。讓我們看看可用的瀏覽器許可權,並考慮應該如何處理它們。 ...

  • 發佈於 2021-03-19 02:23
  • 閲讀 ( 50 )

10個快速的firefox調整,最大限度地提高您的線上隱私

... Facebook可能是一個很受歡迎的網站,但它在隱私方面的聲譽卻很糟糕。Facebook在網際網路上跟蹤你,記錄你訪問的網站和你接觸的內容型別的資料。 ...

  • 發佈於 2021-03-21 13:37
  • 閲讀 ( 56 )

chrome os和google chrome的7項基本隱私設定

...意味著谷歌可以看到你搜索的所有內容和你訪問的每一個網站,無論你是否使用谷歌搜尋引擎,即使你改變主意,決定不訪問某個網站或開始搜尋。你對谷歌瞭解你這麼多感到滿意嗎? ...

  • 發佈於 2021-03-22 02:17
  • 閲讀 ( 91 )

Cookie並不都是壞的:在瀏覽器上啟用Cookie的6個理由

...談論網路上的cookies時,我們指的是HTTP cookies。HTTP cookie是網站放在計算機上的一個小文字檔案。它通常包含三條資訊:名稱、值和一系列屬性。 ...

  • 發佈於 2021-03-23 13:01
  • 閲讀 ( 55 )

10網際網路安全注意事項

... 有些網站提供建議,即字母數字和特殊字元的混合。有些人不接受不符合他們要求的密碼。然而,並不是所有的網站都提供這種服務。當您建立自己的密碼時,請記住您是在保...

  • 發佈於 2021-03-26 19:04
  • 閲讀 ( 48 )
umq9l1
umq9l1

0 篇文章

作家榜

  1. admin 0 文章
  2. 孫小欽 0 文章
  3. JVhby0 0 文章
  4. fvpvzrr 0 文章
  5. 0sus8kksc 0 文章
  6. zsfn1903 0 文章
  7. w91395898 0 文章
  8. SuperQueen123 0 文章

相關推薦