I’m trying to understand the principle behind the Facebook plugins.
As I understood they set a cookie when you login, and then whenever you visit a website with their plugin installed, they are abel to recognize your userId..
I’m trying to do it on my own on a couple of different domains I have, but I don’t know where to start actually…
I set a cookie TEST when I visit site1.com with a random id value
but then when i visit site2.com what should I do? I can I read the previous cookie that contains my id?
When you set a cookie in
site1.com, whenever the visitor visitssite1.com, the cookie would be sent to this website. There is no involvement ofsite2.comat all.site.comcan not and should not be able to receive the cookie that was set bysite1.com.If you are designing a page such that the user visits
site2.comand the web page atsite2.comcontains an IFRAME that loadssite1.com, then the cookie that was set bysite1.comearlier would be automatically sent tosite1.comwhen it tries to load it in this IFRAME.Also, note that these things are usually not done with JavaScript. Some sort of server side scripting such as PHP, ASP.NET, Django, etc. is used to set and read cookies sent by the client. Setting a cookie in the user’s browser involves adding a ‘Set-Cookie’ header to the HTTP response generated by the server-side script. In PHP this can be done using setcookie(). Once the cookie is set in the browser, when the user visits the same website again before the cookie expires, the browser sends the cookie as a ‘Cookie’ header. The server-side script can now read this cookie. In PHP, the cookies are available in
$_COOKIEvariable.