What about using sessions? Store and retrieve credits from session storage using
session_start();
$credits = $_SESSION['credits'];
at the top of your script and
$_SESSION['credits'] = $credits;
at the bottom.
This way credits will be preserved between page-loads.