Please try this code again:
<?php
if (!session_id()) session_start();
if(isset($_SESSION["WA_Store_Cart_UPS_Quote"])) {
unset($_SESSION["WA_Store_Cart_UPS_Quote"]);
}
?>
I have added the session start to the top.
You will need to add this code to the top of your confirm page, since that where the shipping cost is being calculated.