Help with $_Session variable.

SandnSurf

Life's a Beach!
Nov 30, 2006
366
2
0
Australia
First off I my knowledge of PHP is minimal. Just enough to kludge stuff together for my purposes.
Anyway, on my lander I have an order button. When the visitor clicks that he's taken to the merchant's page via a php redirect. In between those actions I capture the referrer detail & write to a db. So the path is:
lander -> db capture page -> redirect to merchant.

To capture the referral detail & pass to the db capture page I use the following code on the lander:
Code:
session_start();                      
$_SESSION['myref'] = $_SERVER['HTTP_REFERER'];
On the capture page I have:
Code:
session_start();
$_SESSION['myref'];
and I write the session to the db before passing the visitor to the merchant.

What's happening though is quite a few visitors are not being recorded. I can compare directly with merchants stats to see this. I'm thinking that what's happening is that when multiple visitors land at same time, only one session is being captured. If this is the case, how do I keep track of concurrent visitors sessions?
 


I can compare directly with merchants stats to see this. I'm thinking that what's happening is that when multiple visitors land at same time, only one session is being captured. If this is the case, how do I keep track of concurrent visitors sessions?

No that is not a problem. The problem of people not tracking through your session is probably because people have cookies disabled. Passing the referrer as a GET variable instead of storing in the $_SESSION var would solve your problem.
 
Thx for that. At the moment I'm thinking it may be more to do with characters passed in some of the referrers & the regex used to parse the domain from the referrer. I tested by writing to a txt file using the "a+" append option. What I'm seeing is a list of referrers ( as it should be) but every now and then a referrer comes through that clears all previous data. Not sure exactly what's going on.
 
What I'm seeing is a list of referrers ( as it should be) but every now and then a referrer comes through that clears all previous data. Not sure exactly what's going on.

Do you mean it's clearing your txt file, or is theirs just blank?
 
Thx for that. At the moment I'm thinking it may be more to do with characters passed in some of the referrers & the regex used to parse the domain from the referrer. I tested by writing to a txt file using the "a+" append option. What I'm seeing is a list of referrers ( as it should be) but every now and then a referrer comes through that clears all previous data. Not sure exactly what's going on.

OK, without seeing the code there is nothing more I can do. Also keep in mind that if users have any "Anonymous browsing" software installed, (Norton internet security has an option for it I think) that this software usually wipes the referer http header field.
 
Your not going to get accurate tracking with the $_SERVER['HTTP_REFERER'] for AN array of reasons.

If you don't want an ugly URL for the button then do this.

Setup a page lets say orderRedirector.php

On that page use $_GET['orderID'], $_GET['productID'] whatever you need and will pass through $_GET.

Use your .htaccess to rewrite the URL exampe:

RewriteRule ^orders/product-([0-9]*)-([0-9]*).html$ /orderRedirector.php?idProduct=$1&idOrder=$2&action=purchase [L]

OR THIS WOULD WORK TOO:

RewriteRule ^orders/([0-9]*)/([0-9]*)/$ /orderRedirector.php?idProduct=$1&idOrder=$2&action=purchase [L]

Now you can send your order form to a nice tracking url on your site using get :)

Just for clarity sake your order button would link to something like this:

http://www.yoursite.com/orders/product-123-123.html

That will solve your problem without sessions.