Real Madrid needed extra time to beat Real Sociedad in the Copa del Rey semi-final second leg at the Santiago Bernabeu.