Checks if 3rd party cookies are allowed in client web browsers.
Inspired by @mindmup's 3rdpartycookiecheck.
- Secure web server that runs on https and can host static html files.
- NodeJS (optional, if static website is to be run on localhost)
- node version: 10.16.3
- npm version: 6.9.0
-
Clone this repository.
git clone https://github.com/weaponsforge/thirdpartycookie.git
-
Install dependencies (For localhost viewing only. 3rd party cookies checking won't work from files served on localhost. However, the production app can be used from localhost. See Usage for more information).
npm install
-
Run the localhost server.
npm run start
-
Load the local website client for more usage information.
http://localhost:3001
-
(Optional) Upload
check.html
andcomplete.html
in a secure web server that runs in https and call "check.html" from there i.e.,https://[YOUR_SECURE_SERVER]/check.html
-
Create an
<iframe>
. -
Point its
src
tohttps://<your-secure-domain>/thirdpartycookie/check.html
. i.e.,
<iframe src="https://thirdpartycookie.firebaseapp.com/check.html">
-
Listen for a window "message" event that will be issued using
window.postMessage()
from the iframe's child.var receiveMessage = function(evt) { if (evt && evt.origin === window.location.origin) { if (evt.data === 'MM:3PCunsupported') { console.log('--3RD PARTY COOKIES ARE N-O-T SUPPORTED!!') } else if (evt.data === 'MM:3PCsupported') { console.log('--3RD PARTY COOKIES ARE SUPPORTED') } } } window.addEventListener("message", receiveMessage, false)
thirdpartycookie:
https://thirdpartycookie.firebaseapp.com/.
[1] - S.O. check if third party cookies are enabled
[2] - 3rd party cookies in practice
[3] - document.cookie
@weaponsforge
20200313