Yes, they do, but as you said the cost is divided per year of the contract. So the player gets the money up front, but only a fraction of it counts against the cap each year.
Unless the player is released, at which point all remaining yearly cap bonuses are lumped together to count against the cap the year he is released (or is it spread out over two years?). Either way, this is all going to pot because of the uncapped year in 2007.