Answer the question
In order to leave comments, you need to log in
Setting a cookie on a request from a different domain - is it possible?
Good afternoon. There are two sites. On site "A" I need to go to site "B" imperceptibly for the user so that I can see this call on the latter and set a cookie for this user (anonymous).
On site B, the code looks like this (conditionally):
if (!empty($_GET['ref'])) {
setcookie('ref', $_GET['ref'], time()+60*60*24*7, '/');
}
<iframe src="https://siteB.ru/?ref=123"></iframe>
<img src="https://siteB.ru/?ref=123" />
<link href="https://siteB.ru/?ref=123" rel="stylesheet">
<div style="background:url('https://siteB.ru/?ref=123');"></div>
Answer the question
In order to leave comments, you need to log in
Do you set the SameSite flag when setting cookies?
https://habr.com/ru/post/492830/
https://blog.chromium.org/2020/02/samesite-cookie-...
https://developer.mozilla.org/en-US/docs /Web/HTTP/...
They also often make mistakes in setting cookies, not setting the secure and path parameters correctly.
And so the classic tracking pixel through img src
is still enough to track the user.
imperceptibly address on behalf of the user to a third-party site so that he sees it as a normal visitor visit.
Most advanced users and even modern browsers block third party content. These are not only cookies, but also any other objects, even counters or advertisements.
By all means, cookies are stored and transmitted. I personally used via <img src="">. But the affiliate fires this moment and simply does not send set-cookie headers for such requests (that's why it doesn't exist).
There's always a reverse threaded bolt for every tricky asshole.
You just need to use localStorage instead of Cookie, there will definitely not be such problems there. On site A, open a frame, and on site B, put some marker in storage. I myself try to use cookies to a minimum, antiviruses really like to clean them, as well as various ad blockers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question