Vangar

Tracking class using cookies

Jan 22nd, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. /* PHP Tracker class. Version shithouse 0.2 lol
  4.  * Evan Harrison 2012
  5.  */
  6.  
  7. class tracking {
  8.  
  9.     var $cookievar;
  10.  
  11.     public function start_cookie($cookievar) {
  12.     if (isset($_COOKIE)) {
  13.         if ($_COOKIE[$cookievar] == '') {
  14.         tracking::create_cookie($cookievar, $_SERVER['HTTP_REFERER'], time() + 3600);
  15.         //echo "This is a new cookie";
  16.         } else {
  17.         $this->cookievar = $_COOKIE;
  18.         }
  19.     }
  20.     }
  21.  
  22.     private function create_cookie($name, $ref, $expire) {
  23.     if (isset($_SERVER['HTTP_REFERER'])) {
  24.         $this->cookievar = setcookie($name, $ref, $expire);
  25.     } else {
  26.         // code to handle no referer here
  27.     }
  28.     return true;
  29.     }
  30.  
  31.     public function output($cookievar) {
  32.     if (isset($_COOKIE[$cookievar])) {
  33.         $success = $_COOKIE[$cookievar];
  34.     } else {
  35.         $success = "<p>No cookie of that name found.</p>";
  36.     }
  37.     return $success;
  38.     }
  39.  
  40.     public function destroy_cookie($cookievar) {
  41.     $cookievar = setcookie($cookievar, "", time() - 3600);
  42.     return $cookievar;
  43.     }
  44.  
  45. }
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment