简体   繁体   中英

Setting a cookie from a third-party domain

So basically, what I am trying is to build a simple tracker as a method of learning how trackers work. And I stumbled upon my first problem. The scenario is like this:

  • Domain A , which loads the JS (tracker) from Domain B
  • Domain B , which hosts the tracker and backend

User loads Domain A, and the JS is loaded successfully. A Set-Cookie (name, value, path, expiration) request is sent by Domain B to the user, which receives it (I checked it). However, it doesn't actually set the cookie in the browser. I tried to do the same but everything in the same domain and works, so the problem is that they're different domains.

What is the best workaround for this? Using iframes, maybe? Setting the cookie from the JS reading the response from the server?

Toss this in your http headers

P3P CP="NOI COR NID CUR OUR NOR"

P3P is the key, the rest is the value

And you'll propably want to brush up on what P3P actually is http://www.w3.org/P3P/

or just google "P3P"

In this thread they say P3P is dead ..but it will still work on IE. Don't know where chrome & FF stand on this issue. Any recommendation for p3p policy editor?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM