PHP拒绝接受cookie

When I develop web page Faced a problem which happen when use session

<?php
session_start();
ob_start();
    if ($type == 'admin') {
                $_SESSION['user_name'] = $User;
                $_SESSION['UserType'] = 'admin';
                header('Location: Main.php');
            } else if ($type == 'manager' && $PID != "") {
                $_SESSION['user_name'] = $User;
                $_SESSION['UserType'] = 'manager';
                $_SESSION['PID'] = $PID;
                header('Location: MainPage.php');
            }
?>

this Error in all my cases:

"Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept cookies."

this Error in all my cases

Your script looks like that youre redirecting in a circle. Main.php-> main.php -> main.php and so on. Check your script for such a mistake