File size: 403 Bytes
bb33d30
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { browser } from "$app/environment";

export function cookiesAreEnabled(): boolean {
	if (!browser) return false;
	if (navigator.cookieEnabled) return navigator.cookieEnabled;

	// Create cookie
	document.cookie = "cookietest=1";
	const ret = document.cookie.indexOf("cookietest=") != -1;
	// Delete cookie
	document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
	return ret;
}