Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cookie_name = "last_page";
- $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
- // If the cookies does not exist, it is created:
- if(!isset($_COOKIE[$cookie_name])) {
- setcookie($cookie_name, $actual_link, time() + (86400 * 30));
- echo "<br/>first visited<br/>";
- } else {
- // Check if the cookie -URL saved- is not equal to the current URL, and if the HTTP_REFERER is written from the address bar:
- if ($actual_link !== $_COOKIE[$cookie_name] and strlen($_SERVER["HTTP_REFERER"]) == 0){
- header("Location: " . $_COOKIE[$cookie_name]);
- // Update the cookie with the new URL:
- setcookie($cookie_name, $actual_link, time() + (86400 * 30));
- exit();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement