fingerprintjs

Форк
0
/
cookies_enabled.ts 
29 строк · 1.4 Кб
1
/**
2
 * navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking
3
 * cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past with
4
 * site-specific exceptions. Don't rely on it.
5
 *
6
 * @see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js Taken from here
7
 */
8
export default function areCookiesEnabled(): boolean {
9
  const d = document
10

11
  // Taken from here: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js
12
  // navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking
13
  // cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past
14
  // with site-specific exceptions. Don't rely on it.
15

16
  // try..catch because some in situations `document.cookie` is exposed but throws a
17
  // SecurityError if you try to access it; e.g. documents created from data URIs
18
  // or in sandboxed iframes (depending on flags/context)
19
  try {
20
    // Create cookie
21
    d.cookie = 'cookietest=1; SameSite=Strict;'
22
    const result = d.cookie.indexOf('cookietest=') !== -1
23
    // Delete cookie
24
    d.cookie = 'cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT'
25
    return result
26
  } catch (e) {
27
    return false
28
  }
29
}
30

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.