Contention Based Handover: When the Handover requires Random Access Procedure.
When the handover is Contention based, UE would be informed by the source eNodeB through rrcConnectionReconfiguration message.
Explanatory: In RRCConnectionReconfiguration message, It has mobilityControlInfo Information Element. Which has another field called new-UE identity, which contains the info of RandomAccessPreambleIdentifier.
This preamble will be selected by the UE and will be transmitted in the available sub-frame. The target eNodeB answers using the same preamble and will assign the temporary C-RNTI to UE. This is how the C-RNTI will be exchanged.
UE will get the information of his new C-RNTI and UE will use this information in MSG3 of handover.
I hope I have answered your query. Further doubts are welcome.