Session help
Posted: Mon Apr 23, 2007 3:19 pm
feyd | Please use
I also tried this:
Then on another page that I connect back to later on for tracking contains the following code:
Everything that uses GET works but the sessions are not output. When I echo them on the index they work fine but not here so I am getting the referring url correctly. Sessions are set up correctly because I use them in other places on the site.
Help!
Thanks,
Ryan
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I am trying to store the referring URL of customers so that when they make a purchase it connects to a page and records that URL with some other info in a text file for tracking purposes.
First, on the index page, I include a file that uses session_start(); while doing it's other functions then I have done this after the include:Code: Select all
if (!$_SESSION['refURL']) {
$_SESSION['refURL'] = getenv('HTTP_REFERER');
}Code: Select all
if (!isset($_SESSION['refURL']) || $_SESSION['refURL']=='') {
$_SESSION['refURL'] = getenv('HTTP_REFERER');
}Code: Select all
<?
session_start();
$refURL = $_SESSION['refURL'];
if (!$refURL) $refURL = "a direct request or unknown link";
$refId = $_SESSION[refid];
if (!$refId) $refId = "advertising or search engine";
$transId = $_GET['transId'];
if (!$transId) $transId = "not known";
$total = $_GET['total'];
if (!$total) $total = "an unknown amount of";
$output = "Transaction number $transId, totaling $total dollars was referred by $refId originating from $refURL\n";
$file = fopen("tracking.txt", "a");
fwrite($file, $output);
?>Help!
Thanks,
Ryan
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]