Storing Referer Info in Session Variable

Discussion in 'PHP' started by LazyD, Jul 17, 2007.

  1. #1
    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?
     
    LazyD, Jul 17, 2007 IP
  2. JOGS_DEV

    JOGS_DEV Peon

    Messages:
    136
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sure, you can use session variables for this, there aren't any downsides at all.
    Code will look something like:

    $_SESSION['keywords'] = string containing your keywords;

    You can then access $_SESSION['keywords'] on any other page of your website, but don't forget to include session_start(); at the top of all scripts.
     
    JOGS_DEV, Jul 17, 2007 IP
  3. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #3
    since referer info is set in browser, you can't trust that info.
     
    gibex, Jul 17, 2007 IP
  4. LazyD

    LazyD Peon

    Messages:
    425
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I know that referrer information is easily spoofed and set by the browser - But for what im doing it will be fine...
     
    LazyD, Jul 17, 2007 IP