Link to home
Start Free TrialLog in
Avatar of MirageSF
MirageSF

asked on

Referrer ID's being passed page to page

Hi,

checkout http://www.xcensus.com

I would like to be able to pass a variable such as www.xcensus.com?affid=0111 to any page on my site and for it to get picked up on the signup pages, whats the best way to achieve this, and the code needed to make the idea work ?  

Regards
ASKER CERTIFIED SOLUTION
Avatar of VGR
VGR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KC_Speedball
KC_Speedball

the best and cleanest (not the easiest) way is to use session.


the code will be like this:

<?php
session_start();
register_session('affid');


$_SESSION['affid'] = 0111;

for the first page

any other page have to contain

<?php
session_start();
register_session('affid');

and than you can you $_SESSION['afid'] in the script consisting the value from the first page
Again VGR *grrr* the fastest coder on earth :). Rien ne va plus! Thanks for learning from you.
not at all the fastest 8-)
just the one working also on Sunday :D
it looks like working 24 hours 7 days a week for me
Avatar of MirageSF

ASKER

Hmm, but surely the first method would be forgotten if they moved to another page ?  Hows about a cookie, as I would also like it to remember that affid for 30 days from when its first visited ?

Regards
never worked with cookies. job for VGR
yeah but cookie is not reliable....
but for your purpose cookie is the only solution...
regards
absolutely not, carchitect !
Cookies (I mean EXPLICIT cookies) are the WORST solution I would try. Only in Despair would I use them.

Sessions ***usually*** involve cookies too (or files on the server)

if they go to another page, id doesn't change anything because you redirect to the "signup page" anyway. I thought you wanted the affid to be transmitted forward, but if you don't, no problem, it's even simplier :
if (isset($_GET["affid"])) {
 Header("Location: yoursignup.php");
} // if transmitted via GET (in the URI)

this way ANYTIME affid is sent via the (direct) URL, the browser is redirected to yoursignup.php

That's what you asked for, isn't it ? :D
Erm....  They will always be sent to http://www.xcensus.com/index.php?affid=(anynumber)

Then I really need this number stored for upto 30 days, so if that person visits the site during that time again without including the ?affid bit then when they move throughout the site and eventually sign up, the affid originaly number is picked up from their machine somehow.
30 days --> cookies only. Nor for me.

sessions won't last that long, and are closed when changinf browser's instance, so in 30 days and given Zindoze 's ability to "blouscrine"... Around 120 sessions in 30 days :D

you could have stated this in your originalquestion. I answered it 100% and now that was not what you wanted !

"ce qui se concoit bien s'enonce clairement,
et les mots pour le dire viennent aisement."
Sorry, youre right, I was just tired ! :)
VGR i know cookie is worst and i never use it personally...
ha ha
thanks, I'll cool down... perhaps adding some heat sinks to my exoskeleton...