Results 1 to 11 of 11
  1. #1
    Newbie
    Join Date
    March 15th, 2006
    Posts
    12
    Which PHP Method will work best?
    I have a website for registered and non-registered users. The registered users each have a unique ID assigned to them that is stored in a MySQL database. I am just trying to figure out the best way to append this ID to the end of each URL so I can track the clicks for each of my registered users.

    So for example:
    If a non-registered user goes to my site, their URL would be www.mysite.com/index.php. For a registered user (after logging in) I would want the same URL to function as www.mysite.com/index.php?id=1 instead. (with ID being the unique value stored in the database for that particular registered user.)

    Can anyone recommend the most effective way to accomplish this task? Extra credit if you can tell me if this can be done using Joomla/Mambo


    PS - I searched the forums but I could not find an exact answer to this question; I apologize in advance if this was already covered somewhere else.

  2. #2
    Animal Lover
    Join Date
    January 18th, 2005
    Location
    oz
    Posts
    1,210
    You'd have to use some form of session control - either with session variables or with cookies - that's how I would do it anyway. These are set when the person logs in and the variable is kept 'live' until that person closes that session ie closes the browser...you can set it so that it 'times out' after 1/2 hour or something. Otherwise you'll be left with passing that variable as a parameter (which is possible but isn't the best way of doing it).

    Oscar
    My DataFeed Scripts - php datafeed scripts for your site
    Shareasale datafeed scripts - to display Shareasale datafeeds
    Linkshare datafeed scripts - for multiple Linkshare merchants

  3. #3
    Newbie
    Join Date
    March 15th, 2006
    Posts
    12
    Thanks Oscar.

    I will do more research on session variables to see how I can make them work for my purposes. I am using Mambo/Joomla, so I know there is already some sort of session variable being used in this CMS system. I just need to figure out where they are stored and how to modify the code so it will work for my purposes. I have no clue on how to do this right now; I can't figure out how to modify the session code so I can pass data from the SQL database into my URL's.

    Is this something that is hard to do? Do you have any advice or recommended links that have tutorials for this? Your help is appreciated very much.

  4. #4
    Newbie
    Join Date
    March 15th, 2006
    Posts
    12
    Follow-Up Question
    A session ID is already created when a user logs into my system. Their username, ID, and session ID are all stored in a separate table in my database in MySQL called "session".

    Now that I know that data is available and being stored when a user logs in, how do I pass the ID field from the user to the end of my URL's when someone clicks to goto an external site? For example, I would like add "&ID=123" to the end of my hyperlinks where "ID" is a value stored in my session table for the user.

    Can anyone help with this? Any feedback is appreciated.

  5. #5
    Newbie TheHoff's Avatar
    Join Date
    March 5th, 2006
    Posts
    260
    Is there a reason to put it in the URL string?

    I would set a cookie with their session ID. You can have it timeout after 30 mins or an hour:

    <?php

    setcookie("cookiename",$session['sessionid'],"/",time()+3600);

    ?>

    ^^ off the top so check php.net if the syntax is off

    You can then check the sessionID of that user from any page by looking at:

    $_COOKIE['cookiename']


    Quote Originally Posted by Dan76
    A session ID is already created when a user logs into my system. Their username, ID, and session ID are all stored in a separate table in my database in MySQL called "session".

    Now that I know that data is available and being stored when a user logs in, how do I pass the ID field from the user to the end of my URL's when someone clicks to goto an external site? For example, I would like add "&ID=123" to the end of my hyperlinks where "ID" is a value stored in my session table for the user.

    Can anyone help with this? Any feedback is appreciated.

  6. #6
    Newbie
    Join Date
    March 15th, 2006
    Posts
    12
    Yes, the reason why I am looking to put it in the URL string is because I am trying to track conversions for my affiliate advertising. I want to add my user's ID to the end of my URL's so I can match up my affiliate sales by the user who clicks on the ads. Is there an easy way to do this?

    I have a cookie in place already that creates a session id for each user logging in, but I don't know how to append the user ID to my URL's. Do you know how to do this?

  7. #7
    Newbie TheHoff's Avatar
    Join Date
    March 5th, 2006
    Posts
    260
    Sure-- wherever you have an affiliate link, append the cookie.

    http://www.example.com/affiliate.php?i=215&b=1653

    and on the end of that add

    <?=$_COOKIE['sessionid']?>

    so---

    http://www.example.com/affiliate.php?i=215&b=1653&<?=$_COOKIE['sessionid']?>

    Quote Originally Posted by Dan76
    Yes, the reason why I am looking to put it in the URL string is because I am trying to track conversions for my affiliate advertising. I want to add my user's ID to the end of my URL's so I can match up my affiliate sales by the user who clicks on the ads. Is there an easy way to do this?

    I have a cookie in place already that creates a session id for each user logging in, but I don't know how to append the user ID to my URL's. Do you know how to do this?

  8. #8
    ABW Ambassador PatrickAllmond's Avatar
    Join Date
    September 20th, 2005
    Location
    OKC
    Posts
    1,219
    Dan76,

    It looks by the conversation that there are some different definitions of what a session is. You don't have to create a session - it is automatic whenever somebody visits your website. You can store settings, variables, etc. in session variables that are retained for that 'Session'. No mysql work is really needed to store anything about sessions. That is extra. Sessions are also stored on the server side and

    Use session variables if you can rather than cookies.


    P
    ---
    This response was masterly crafted via the fingers of Patrick Allmond who believe you should StopDoingNothing starting today.
    ---
    Focus Consulting is where I roll | Follow @patrickallmond on Twitter
    Search Engine Marketing | Search Engine Optimization | Social Media | Online Video

  9. #9
    Newbie TheHoff's Avatar
    Join Date
    March 5th, 2006
    Posts
    260
    Sorry about the confusion. There are the PHP Sessions that are automatic as described by patrick24601... but I'll also set a cookie with a "Session ID" -- which is sounds like what Dan is doing. Personally I prefer cookies rather than PHP sessions for user tracking.

    Quote Originally Posted by patrick24601
    Dan76,

    It looks by the conversation that there are some different definitions of what a session is. You don't have to create a session - it is automatic whenever somebody visits your website. You can store settings, variables, etc. in session variables that are retained for that 'Session'. No mysql work is really needed to store anything about sessions. That is extra. Sessions are also stored on the server side and

    Use session variables if you can rather than cookies.


    P

  10. #10
    Animal Lover
    Join Date
    January 18th, 2005
    Location
    oz
    Posts
    1,210
    Patrick's right and so's theHoff (as in David??)...I'm with Patrick with this one - I like sessions but that's because not everyone has cookies turned on.

    If you use a jump script then you can also track the clicks on your end (ie on an SQL database). If all you want is to track the sales on the merchant end and the merchant provides that info (ie url from which the sale came) then just appending it to the affiliate url will suffice - if you work it this way, you can't really track those whose clicks don't convert, you're only tracking those who do.

    cheers,
    Oscar
    My DataFeed Scripts - php datafeed scripts for your site
    Shareasale datafeed scripts - to display Shareasale datafeeds
    Linkshare datafeed scripts - for multiple Linkshare merchants

  11. #11
    Lite On The Do, Heavy On The Nuts Donuts's Avatar
    Join Date
    January 18th, 2005
    Location
    Winter Park, FL
    Posts
    6,930
    if cookies are off, no sales credit... build functions that use cookies and warn those who reject cookies that they are missing out on some features / functionality... if you lose them, who cares anyhow.

  12. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Need php code work
    By RH&A in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: March 21st, 2007, 08:03 AM
  2. looking for php/mysql work
    By spiderninja in forum Midnight Cafe'
    Replies: 0
    Last Post: January 31st, 2007, 11:12 PM
  3. PHP/MYSQL Method to Display Merchant Promotions
    By squidnunc in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: January 11th, 2004, 04:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •