使用php标题刷新页面('location')

I want use a single php file to handle all of my voting requests.

Currently the script will, if siteType isn't set, forward the user and display a message. If the user has JS on then it will return a json object and ajax the page.

        if(!isset($_COOKIE['siteType'])){
            displayMessages('bad', 'Before you can continue you must select which category you would like to be in.');
            header('Location:/');
            exit;
        }

I need it as that if this php code above is executed the page will reload, i assume with javascript and reading the http headers?

[Edit] I didn't make myself clear enough, but this is a ajax request. I don't output any html. So this really is just about getting js to handle the header?

You can't Refreshing a page with javascript using php header('location') Because, header('Location: xxx'); must be the only output of your PHP script, it is a header, you can not put it after javascript syntax

Maybe this would be some solution for you,

if(!isset($_COOKIE['siteType'])){
     displayMessages('bad', 'Before you can continue you must select which category you would like to be in.');
     echo '<script>window.location.reload()</script>';
     exit;
 }

PHP

echo '<meta http-equiv="refresh" content="0">';

Javascript

window.location.reload();