Advertisement
Fhernd

page.tpl.php

Sep 19th, 2016
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2.     $cookie_name = "last_page";
  3.     $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  4.  
  5.     // If the cookies does not exist, it is created:
  6.     if(!isset($_COOKIE[$cookie_name])) {
  7.         setcookie($cookie_name, $actual_link, time() + (86400 * 30));
  8.         echo "<br/>first visited<br/>";
  9.     } else {
  10.         // Check if the cookie -URL saved- is not equal to the current URL, and if the HTTP_REFERER is written from the address bar:
  11.         if ($actual_link !== $_COOKIE[$cookie_name] and strlen($_SERVER["HTTP_REFERER"]) == 0){
  12.             header("Location: " . $_COOKIE[$cookie_name]);
  13.             // Update the cookie with the new URL:
  14.             setcookie($cookie_name, $actual_link, time() + (86400 * 30));
  15.             exit();
  16.         }
  17.     }
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement