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

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

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.

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>

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?

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

It’s a small oversight with the code I gave you. Line 8 should finish with a semi-colon, that’s all.

<?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

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.

how about a wordpress plugin to do this?