The process of storing/banking umbilical cord blood starts almost immediately after delivery, though the process differs depending on whether it was a vaginal delivery or a cesarean section.
After the baby has been delivered, the umbilical cord is clamped on both sides (the cord is normally clamped during deliveries prior to being cut), then cut 'off' the child (once again, as done with traditional deliveries regardless of whether the cord blood is being collected or not.)
The actual blood collection from the umbilical cord and placenta can at this point be done either after the placenta has been delivered, or in-utero (prior to delivery of the placenta), with the latter being more common.
When done in-utero, a needle is normally inserted into a small vein in the umbilical cord first, which collects the blood from the cord itself. Afterwards, additional needles are used on the placenta to collect additional blood that had not been passed into the cord.
When done after the placenta has been delivered, the same extraction technique with needles is normally used - though some practitioners prefer to use a gravity-draining technique at this point.
Regardless of which technique is used, the procedure is painless to the mother (after birth the placenta is detached - and therefore there is no direct physical sensation remaining), and because the natural birth process is not being altered in any way, there are no significant dangers to the child.
Cord Blood is typically collected ex utero following a cesarean section (c-section), and follows the same collection techniques as after a vaginal delivery (above) once the placenta has been removed.
There is usually slightly less cord blood extracted after a caesarian delivery because the attending physician is more occupied with the surgery at hand, which includes post-delivery procedures. As a result, some blood is normally lost while waiting for collection as a matter of priority.
Regardless of the particulars, a special kit is required in order to collect the cord blood for transportation to the banking facility. This kit is normally provided by the facility that will be receiving/banking the cord blood (in advance), whether that's a public or private bank. Be sure to have the needed kit with you during delivery, most hospitals do not have the necessary kits available.
Once the blood has been collected, the kit is packed up and sent (usually via courier - the faster the better) to the cord-blood banking facility, at which point the blood is identified appropriately, stem cells are separated from the rest of the blood, then cryogenically frozen and stored.
When stored cryogenically, cord blood/stem cells do not deteriorate with time, so can theoretically be stored indefinitely (forever).
This is based off only a few decades of practical application however, very long term storage has yet to be proven due to the relative infancy of the procedure.