SHARING COOKIES BETWEEN SUBDOMAIN.DOMAIN.COM AND .DOMAIN.COM

Hello,
I'm trying to install affiliates and marketplace plugins to work together.
I would like affiliates referrals to be valid across all network:
affiliate link -> main domain -> any subdomain -> product sale
Can you help in how i should do it?
+Thank you!