Last active
August 29, 2015 14:22
-
-
Save smunchi/888af1499974a21694da to your computer and use it in GitHub Desktop.
Use of HTTP_REFERER to delete session data
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
| Use of $_SERVER['HTTP_REFERER']; | |
| I assume in a.php | |
| <?php | |
| session_start(); | |
| $_SESSION['hello'] = "Your content here"; | |
| ?> | |
| In b.php you want to show your session data and you are also checking what is the previous page | |
| <?php | |
| session_start(); | |
| $previousUrl = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH); | |
| if($previousUrl == '/phpTest/php/c.php') { | |
| unset($_SESSION['hello']); | |
| } | |
| echo $_SESSION['hello']; | |
| ?> | |
| And in c.php you might have a back button or there is also browser back button | |
| <p>Show your confirmation</p> | |
| <a href="b.php">Back or back from browser button<a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment