SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question remember URL (cookie)

    Can someone point me in the right direction to find; How to remember variables in the address bar so that no matter what page they visit they will still have the same variables that were present when they came into the page. Variables such as, ?utm_domain=mydomain.com&utm_campaign=blue

    this will be for regular html pages for now and then I will eventually need it for PHP pages. Thanks

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you're going to use PHP, then PHP's sessions seems like exactly what you want. You might as well use it for your regular HTML pages - just rename them to .php, or set your server to send .html files through the PHP parser.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need more guidance

    Thank you for answering, however I literally have no idea how. I tried this from the info you gave me:
    <?php
    session_save_path('/home/ourpage.com/sessions');
    ini_set('session.gc_probability', 1);
    session_save_path(realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/session'));
    ?>

    checking <a href="http://ourpage.com/lp">lol</a>

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how about a wordpress plugin to do this?

  5. #5
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The link I gave you is rubbish. The entry for session_start is probably all you need to know. It's a simple way of communicating data across a user's session visiting your page:

    PHP Code:
    <?php

    session_start
    ();
    if (!isset(
    $_SESSION['utm_domain'])) { // check for something that would definitely be in session if user had visited before
      
    $qpairs parse_query($_SERVER['QUERY_STRING']);
      foreach (
    $qpairs as $key => $value) {
        
    $_SESSION[$key] = $value
      
    }
    }

    function 
    parse_query($var) {
      
    $var explode('&'html_entity_decode($var));
      
    $arr = array();

      foreach(
    $var as $val) {
        
    $x explode('='$val);
        
    $arr[$x[0]] = $x[1];
      }
      return 
    $arr;
    }
    ?>
    After this first visit, there will be a bunch of $_SESSION variables, one for each item passed in the query string.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php

    session_start();
    if (!isset($_SESSION['utm_domain'])) { // check for something that would definitely be in session if user had visited before
    $qpairs = parse_query($_SERVER['QUERY_STRING']);
    foreach ($qpairs as $key => $value) {
    $_SESSION[$key] = $value
    }
    }

    function parse_query($var) {
    $var = explode('&', html_entity_decode($var));
    $arr = array();

    foreach($var as $val) {
    $x = explode('=', $val);
    $arr[$x[0]] = $x[1];
    }
    return $arr;
    }
    ?>

    <?php
    checking <a href="http://testing.com/index.php?utm_source=ktla">tryingToCaptureInitialUTM's</a>
    ?>








    When using the above code you gave, I get an error:
    Parse error: syntax error, unexpected '}' in /home/testing/testing.com/index2.php on line 8

  7. #7
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's a small oversight with the code I gave you. Line 8 should finish with a semi-colon, that's all.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure how to implement this. Raffles can you implement this in a wordpress/HTML site? How much would you charge? We need to track these cookies. What we are trying to find out is the UTM info or parameters that a user came to the site with, and what page they exited at.
    Thanks

  9. #9
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure how to implement this. Raffles can you implement this in a wordpress/HTML site? How much would you charge? We need to track these cookies. What we are trying to find out is the UTM info or parameters that a user came to the site with, and what page they exited at.

    Anybody?


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •