phpwebcookiescookiestore

Set cookie for users browser when he access my website through another website


Is there any way to store a cookie in a users browser when he access my website through another website?

Example:

I have website a.com

User sends a request using http://b.com and I'd like to set a cookie for http://a.com with this request.

Is it possible?


Solution

  • What you can do is create a PHP script which sets a cookie but does not output anything. Then you can include this script using for example <img> or <script> tags. As soon as the browser tries to load that URL, it will set the cookies you specify in the header (given the fact third website cookies aren't blocked in the browser).

    Then the cookie which is set is accessible by any page on a.com