For the login page, set the action of the login for to:
<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>
on the cart page, there may be php error occurring that is preventing the redirect, add the following on line 1 see if an error is occurring:
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');
?>