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
MirageSFAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VGRCommented:
possibility :
on start of each page :
if (isset($_GET["affid"])) {
  $affid=$_GET["affid"];
  Header("Location: yoursignup.php?affid=$affid");
} // if transmitted via GET (in the URI)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KC_SpeedballCommented:
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
0
KC_SpeedballCommented:
Again VGR *grrr* the fastest coder on earth :). Rien ne va plus! Thanks for learning from you.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

VGRCommented:
not at all the fastest 8-)
just the one working also on Sunday :D
0
KC_SpeedballCommented:
it looks like working 24 hours 7 days a week for me
0
MirageSFAuthor Commented:
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
0
KC_SpeedballCommented:
never worked with cookies. job for VGR
0
carchitectCommented:
yeah but cookie is not reliable....
but for your purpose cookie is the only solution...
regards
0
VGRCommented:
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
0
MirageSFAuthor Commented:
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.
0
VGRCommented:
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."
0
MirageSFAuthor Commented:
Sorry, youre right, I was just tired ! :)
0
carchitectCommented:
VGR i know cookie is worst and i never use it personally...
ha ha
0
VGRCommented:
thanks, I'll cool down... perhaps adding some heat sinks to my exoskeleton...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.