hi,
well for that u plz check first that the id that u have given in the session is passing to 2nd page r not by putting an echo .Then if u get means put an if condition for that session id like this for eg.if u put like this means if the session id is !=empty means the page will auomatically redirect to the first page.
if($_SESSION=="")
header("Location:second.php");
else
header("Location:first.php");