Last Updated: February 25, 2016
·
594
· brendanmurty

Redirect

Redirect the user using the most suitable method.

<?
function redirect($url){
if(headers_sent()){
    print '&lt;script&gt;window.location="'.$url.'"&lt;/script&gt;';
}else{
    header('Location: '.$url);
}
exit();
}
?>

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside