1

Okay php newbie here, please bear with me. I am not sure if this is a redundant question but here goes. I have a reference code i want to stick to my url. example: site.com/index.php?refcode=123. That's fine right? we can put anything on there. Naturally the visitor goes to the index page. But if the visitor then clicks on other buttons that leads to other pages in my site, the parameter is gone. Like I want to track which code the visitor has when he sends me an email when he later decides to go to my contact page. How can this be done with php? or can this be done with jquery?

2
  • 1
    a session would probably be the easiest approach. just know that no method will guarantee the user does not change that code Commented Sep 24, 2013 at 3:34
  • agreed. the rest out there won't bother changing the code. I've seen it so many times, marketers giving me links, and guess what.. what keeps me from removing their referral codes? nothing. but people like that are few compared to the millions of people who would rather not touch the url. just saying... can you show me how to create a session to preseve that url parameter? Commented Sep 24, 2013 at 3:49

1 Answer 1

1

You would be best off saving the url variable into a session variable instead. The session variable will stick with the user so you have access to it no matter what page they go to.

$_SESSION['refcode'] = $_GET['refcode'];

Make sure to use session_start()

But if you do want to do it the way you have asked you can modify all urls on your page and add:

'?'.$_SERVER['QUERY_STRING']

This will add the query string to your url so the next page they go to would still have it. But that does seem like a lot more work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.