Say I have a website called a.com, and when a specific page of this site is loaded, say page link, I like to set a cookie for another site called b.com
Here is what I've used. Note, this cookie is passed in the open (http) and is therefore insecure. I don't use it for anything which requires security.
You could probably add encryption/signatures to make this secure. Do your research on how to do that correctly.