Storing Referer Info in Session Variable

Status
Not open for further replies.

LazyD

$monies = false;
Dec 7, 2006
655
12
0
Wine Cuntry
wildfoxmedia.com
So, for a site im working on I would like to track stuff as detailed as possible - One of the things I would like to track is referer information, specifically, keywords from search engines - I already have a script that parses the keyword out of the referer string but I need to figure out how to pass that information along to another page...

I know I can do it by throwing it into the URL and using $_GET vars but I dont want to do that because theres something I dont enjoy about having "some-long-keyphrase-here" in the URL of the page...

I also dont want to use forms to pass it in a POST variable...

So my question is, has anyone ever used sessions to pass information like referer keywords, date/time, etc to another page to be inserted into a database?

Is there any downsides to doing this?
 


Hi,

Why not slap it in the database on the first page?

If you set a cookie on the first page that cookie can
have information which allows the second page to
access the db info if needed.

Only if cookies are off do you need to use session variables really.

Crispin
 
You've at least considered passing it via ugly $_GET vars but you dont want to consider passing it via POST?

POST would be the most effective way to do this.

Other than that, Id say use session variables.

Also, dont forget about the "hidden" form tag (forgive me if you already know this as I dont know your experience level)
HTML:
<form action="storeGoog.php" action="post">
<input type="hidden" name="googleTerms" value="$googleTerms">
</form>
That will pass the variable via POST without showing it anywhere on the screen. Hence, 'type = hidden'.

And Im not 100% sure how youd submit that if you dont already have a form.

But, yeah, session variables.


Also, why would you want to keep passing it if you want to store it in the db? Just store the damn thing when it comes in. Maybe assign the session an ID and keep retrieving it? Sloppy, I know, but it would avoid all this.
 
Crispin, I cant slap it into the DB on the first page because they have not selected a link. Im using a PHP script to dynamically redirect to certain page based on the link they click - pretty much, by the products UPC - So I have to do it on the second(redirect) page since thats when they have selected a product...

Josh, I really dont want to use forms - dont ask me why, but I just feel no need to use them...

Ive already got it setup using Sessions and it works great... Another reason I decided to go with sessions is because they expire after the browser is closed, etc.
 
Why are you refusing to pass it via post?

If your worried about people tinkering with it, setup a smart system, use input validation, something.


So your doing redirections, why dont you just put a function in the first page that, when clicked, it executes the function and dynamically redirects from there?? Maybe? Can you be a little clearer on what your trying to do and maybe I can be of more help...

PS - dont forget about selling mag subscriptions on that surfing site. /me is a surfer.
 
I really need to learn how to do this stuff. I'm going to dig into PHP for the first time this weekend but seriously... this is the meaty stuff that most people don't do.

sorry i have nothing of value to add!
 
Hey,

Do this:

session_start();
$_SESSION['keyword'] = $keyword;

And then on every page you want to use the keyword:

session_start();
echo $_SESSION['keyword'];

Yes, it's that damn easy.


Tob
 
I got it all setup...

Its already tracked a fuck-ton of clicks, which only a few of, are showing up in my CJ stats. I assume CJ uses some kind of IP scrubbing or something like once the cookie is set it doesn't track that user over again.. Anyone confirm?
 
LazyD, if I understand what you're doing correctly, make sure you aren't submitting the same variable over and over.

krazyjosh, there's no need to use post. In fact, it would be stupid. Because if you want to submit a form, it REQUIRES some kind of user action. Javascript can press the submit button for them, but it can't be in an onLoad or anything. That not only means that every link would have to have a piece of JS in it (though I'm sure that wouldn't be totally necessary), but if the user leaves the page without initiating any JS (or JS is disabled), nothing is passed.

Session variables are definitely the way to go.
 
Status
Not open for further replies.