I am attempting to build a template page that contains content called by using the include construct. I would like the links in this include page to contain tracking variables "exploded" from the URL. One of these variables will be be used in a link on each page, and the other will be used in a single link on a later page.
I have been attempting to use Session variables, but have recently begun to wonder if these variables can be passed to an "include" file. I have tried using the session functions in upper and lowercase without any results, I have tried starting or not starting the session on the include page, I have tried calling the variables without the session function, etc. I'm lost, and have only a few days experience with this type of thing. Can anyone help, please?
Here is the code I have been using in a page called "wrapper.php" -
Many thanks.
<?
session_start();
header("Cache-control: private");
session_register("var0");
session_register("var1");
session_register("var2");
$URL_data = explode("/", getenv("REQUEST_URI"));
$session['var0'] = $URL_data[0] ;
$session['var1'] = $URL_data[1] ;
$_session['var2'] = $URL_data[2] ;
?>
and later in the same file -
<?php echo "Your session ID is: " . session_id();?>< br>
<?php Empty Field? = <?php echo $var0;?><br>
<?php Affiliate Num? = <?php echo $var1;?><br>
<?php Landing Page? = <?php echo $var2;?><br>
<?php include "http://mydomain.com/mycontent.php";?><br>
The following is contained in my page mycontent.php -
<?php
session_start();
?>
<?php echo 'Empty Array = ' . $session["var0"];?><br>
<?php echo 'Affiliate Number = ' . $session["var1"];?><br>
<?php echo 'Page Requested = ' . $_session["var2"];?><br>
The file <?php echo $REQUEST_URI;?> was requested
<br>
All of the variables are populated except the three session variables on the mycontent.php page. I have used the form shown above, and I have called the vriable in the normal manner, as in $var1 or $var2. Neither gave a result.
Will it be possible to use these variables in this manner? If so, what do I need to change?
Many thanks.