PHP session tracking - help required

  • caravan5
  • Novice
  • Novice
  • caravan5
  • Posts: 20

Post 3+ Months Ago

I'm totally new to PHP, so forgive my ignorance, but could anyone tell me where I'm going wrong here?

I'm trying to track visitors to our website who have been referred from other sites. I then want to pass on the affiliate's details when they leave the site.

The following script is at the top of the home page:
Code: [ Select ]
<?php session_start(); $_SESSION["affiliatecode"] = htmlentities(trim(@$_REQUEST["affiliatecode"])); ?>
<?php session_start(); $_SESSION["campaignID"] = htmlentities(trim(@$_REQUEST["campaignID"])); ?>
<?php session_start(); $_SESSION["sourceBusID"] = htmlentities(trim(@$_REQUEST["sourceBusID"])); ?>
<?php session_start(); $_SESSION["activityID"] = htmlentities(trim(@$_REQUEST["activityID"])); ?>
  1. <?php session_start(); $_SESSION["affiliatecode"] = htmlentities(trim(@$_REQUEST["affiliatecode"])); ?>
  2. <?php session_start(); $_SESSION["campaignID"] = htmlentities(trim(@$_REQUEST["campaignID"])); ?>
  3. <?php session_start(); $_SESSION["sourceBusID"] = htmlentities(trim(@$_REQUEST["sourceBusID"])); ?>
  4. <?php session_start(); $_SESSION["activityID"] = htmlentities(trim(@$_REQUEST["activityID"])); ?>

Then at the end of the link to leave the site I've got:
Code: [ Select ]
&affiliatecode=<?php echo @$_SESSION["affiliatecode"]."&campaignID".@$_SESSION["campaignID"]."&sourceID".@$_SESSION["sourceID"]."&activityID".@$_SESSION["activityID"];?>

The idea being that the variables "affilatecode", "campaignID", "sourceID" and "activityID" are passed to the external site.

At the moment, it just passes the affiliatecode and skips the rest.

Any ideas?

Thanks in advance
  • Bozebo
  • Expert
  • Expert
  • User avatar
  • Posts: 709
  • Loc: 404

Post 3+ Months Ago

you only need session_start() once, as the first line of php (per page, not in each set of php brackets)

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 28 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.