How To Redirect To Another Page In jQuery?

Question:
How can I redirect the user from one page to another using jQuery?

Answer:
Solution 1
One does not simply redirect using jQuery.
jQuery is not necessary, and window.location.replace(...) will best simulate an HTTP redirect. It is better than using window.location.href =, because replace() does not keep the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco. If you want to simulate someone clicking on a link, use location.href. If you want to simulate an HTTP redirect, use location.replace.

For example:
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";

Solution 2
$(location).attr('href', 'http://stackoverflow.com')

Source: http://stackoverflow.com/questions/503093/how-to-redirect-to-another-page-in-jquery

PHP Sessions Security

Question:
I am not sure how to explain this, but basically I want users to navigate to a file called index.php on my apache server installed on the root directory on my site.

Whenever they visit this URL, they get a session or cookie, something to tell my server that they visited this site with a timed expiration of 5 minutes. This will redirect them to another site, for example, http://bing.com. Whenever they get redirected to the same index.php on my site, the session will be read and if it is present and hasn't expired, use echo to display an iframe element.

If there is no session or it has expired, redirect to http://bing.com. I have tried this myself, but I am too much of an amateur. Here is my script:

Answer: 
session_start();

if (isset($_SESSION['visit'])) {
    unset($_SESSION['visit']);
    echo '<p>Success</p><br><iframe src=secretpage.html width=100% height=95% frameBorder=0></iframe>';
} else {
    $_SESSION['visit']='true';
    header('Location: http://bing.com');
}

Source: http://stackoverflow.com/questions/39712826/php-sessions-security