The problem with that is that at the beginning (before you make the comparison), there is no $old_count variable, because as it is, the $old_count variable is unset upon the page refresh.
So at the bottom, you want:
$old_count = $cur_count;
$_SESSION['old_count'] = $old_count;
And at the top, you want something like:
session_start();// This has to be the very first line of the page
IF(isset($_SESSION['old_count'])){
$old_count = $_SESSION['old_count']
} else {
$old_count = //some default value (or however you want to handle this)
}