w3c / beacon

Beacon
https://w3c.github.io/beacon/
Other
46 stars 22 forks source link

navegator.sendBeacon cookie visibility question. #63

Closed easher closed 5 years ago

easher commented 5 years ago
function trackClickAndForward() {
     navigator.sendBeacon("https://www.example.com/tracker");
     window.location.href = "https://www.example.com/homePage";
}

Is it guaranteed that sendBeacon's analytics request to 'www.example.com/tracker' will not include any cookies that may be set on the *.example.com domain from the "www.example.com/homePage" response?

igrigorik commented 5 years ago

Following your example, the sendBeacon request is fired and returns immediately, and the browser then proceeds to initiative the navigation to specified URL — these two requests do not block or depend on each other. Does that answer your question?

easher commented 5 years ago

I think so, but maybe that wasn't a good example. Here is a different way of phrasing my question. Are the cookies that will be included in a sendBeacon request guaranteed to be only the cookies set in the browser when navigator.sendBeacon returns true in all scheduling cases? Or could it include cookies that were set after the request was queued, but before the request actually fires?

igrigorik commented 5 years ago

Are the cookies that will be included in a sendBeacon request guaranteed to be only the cookies set in the browser when navigator.sendBeacon returns true in all scheduling cases?

Yes, that should be the case.

easher commented 5 years ago

Cool, thanks for your help @igrigorik!