Try adding this after line 190:
<?php
if (isset($_POST["Update"]) || isset($_POST["Update_x"])) {
die();
}
?>
Some servers will continue processing the code on a page after a redirect which could be your issue. This will stop the code below from running after an update so that the session shouldn't be cleared until after it is actually shown.