Last active
July 10, 2020 18:04
-
-
Save sivinnguyen/ceded97377c7b45bb70936fdce500a06 to your computer and use it in GitHub Desktop.
Safely make A PHP Redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// cs-cart/addons/hybrid_auth/lib/Hybrid/Auth.php | |
// Ensure session is saved before sending response, see https://github.com/symfony/symfony/pull/12341 | |
if ((PHP_VERSION_ID >= 50400 && PHP_SESSION_ACTIVE === session_status()) || (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id())) { | |
session_write_close(); | |
} | |
// https://www.hostinger.com/tutorials/php-redirect | |
// https://www.tutorialrepublic.com/faq/how-to-make-a-redirect-in-php.php | |
// https://upcity.com/blog/6-how-to-redirect-your-site-properly/ | |
// header('Content-type: text/html; charset=utf-8'); | |
header('Location: ' . $url); | |
exit(); // or die() | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment