Mapping First party cookie ID and Third party cookie ID

Hello,
How does piwik server knows about an existing visitor from his first party cookie sent in the _id parameter.?
what we see is that mysite.com sent action under _id=xxx and in the database the action is inserted under the third party cookie visitorId = yyy.

How does such mapping is done.

Regards,

Third party is prioritary over the _id parameter

order:

  • user id
  • cid parameter
  • third party cookies
  • _id parameter