Exxtazy

Untitled

Aug 30th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. /*
  3. * Name: Universal Analytics Cookie Parser Class
  4. * Description: Parses the new format Universal Analytics cookie.
  5. * Developer: Matt Clarke
  6. * Date: January 10, 2013
  7. */
  8.  
  9. class UniversalAnalyticsCookieParser{
  10.  
  11. // Parse the _ga cookie if found
  12. function __construct() {
  13. if( isset($_COOKIE["_ga"]) ){
  14. echo $this->getCid();
  15. }
  16. }
  17.  
  18. // Handle the parsing of the _ga cookie
  19. public function parseCookie()
  20. {
  21. list($version,$domainDepth, $cid1, $cid2) = split('[\.]', $_COOKIE["_ga"],4);
  22. return array('version' => $version, 'domainDepth' => $domainDepth, 'cid' => $cid1.'.'.$cid2);
  23. }
  24.  
  25. // Get cid
  26. public function getCid()
  27. {
  28. $contents = $this->parseCookie();
  29. return $contents['cid'];
  30. }
  31.  
  32. }
  33.  
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment