Magento has a Cookie model, Mage::getModel('core/cookie')
, which provides methods for manipulating cookies. The basic approach you would take would be to drop a cookie which is submitted to both sites (via the cookie's domain property).
However, using this for authentication is a bad idea--it's much, much better handled by an established cross-site security protocol such as OAuth
, which is (moderately) documented on the Magento site.
With OAuth the basic flow is:
- User lands on Site A, which handles authentication. They login and establish a session.
- When user goes to Site B Site B can initiate a handshake with Site A. If the handshake succeeds then user is briefly redirected to Site A to respond to a "Are you sure you want to provide permission to Site B" prompt (or they are prompted to login to Site A, if they haven't done so).
- When the user confirms the prompt they are returned to Site B, with a token indicating their authentication at Site A.