PHP, cookies and frames.

Discussion in 'Site & Server Administration' started by SERPalert, Mar 21, 2006.

  1. #1
    SERPalert, Mar 21, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Because the cookie is matched against the domain in the browser's address bar. Frames from another URL that's not yours as defined in the cookie won't work for security reasons.

    Else that other site can start reading your cookies.
     
    T0PS3O, Mar 21, 2006 IP
  3. chengfu

    chengfu Well-Known Member

    Messages:
    113
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #3
    A cookie is only sent back to the originating domain, but that shouldn't be defined by the browsers address bar. Otherwise e.g. tracking pixels for affiliate networks or webcounters would not work.
     
    chengfu, Mar 21, 2006 IP
  4. chengfu

    chengfu Well-Known Member

    Messages:
    113
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #4
    @SERPalert: Have you tried to check the transmission using an extension like live http headers to see how exactly they are accessing your domain?
     
    chengfu, Mar 21, 2006 IP
  5. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #5
    They execute javascript from the other domain. That code puts a cookie with your aff id. So the cookie originates from the aff domain, not yours, I believe.

    I'm pretty sure it has to come from the browser's address bar, how else would they ensure security in that regard?
     
    T0PS3O, Mar 21, 2006 IP
  6. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can add some code to your site to make it jump out of a frameset.
     
    mad4, Mar 21, 2006 IP
  7. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Correct:

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    if(parent != self){
    top.location.href = location.href;}
    //-->
    </SCRIPT>
    Code (markup):
    I just checked my cookies and I have tons of statcounter.com cookies which proves my point of aff and counter tracking donw on the aff/counter's domain, not yours.
     
    T0PS3O, Mar 21, 2006 IP
  8. chengfu

    chengfu Well-Known Member

    Messages:
    113
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #8
    Ah, ok. Now I understand the problem. I didn't realize that a third-party trackingcookie is creating the problem - or better: the problem is not the cookie but the trackingcode that is using "document.location".
     
    chengfu, Mar 21, 2006 IP
  9. SERPalert

    SERPalert Guest

    Messages:
    1,003
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks, I'm using this code, which is how i spotted the problem.

    Person visits my site, I drop a row in a mysql table and record all sorts of info. THEN it busts out of frames and I get another mysql row. :(

    Don't suppose it's possible to alter that JS to bust out of frames and goto url http://www.mydomain.com/?framebust=1 ?

    My JS sucks
     
    SERPalert, Mar 21, 2006 IP
  10. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #10
    So it DOES read the cookie when in the external frame? :confused:

    Why not check the timestamp and don't add a row if it's less than how long it takes to burst out. or get your PHP to validate the request. Match the URL and if not yours then don;t store it in MySQL.

    Yes it is...

    So does mine so I don't know how :)

    Try:

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    if(parent != self){
    top.location.href = location.href + ?frameburst=1;
    }
    //-->
    </SCRIPT>
    Code (markup):
    Can't remember whether a string is extended by a period or a plus.
     
    T0PS3O, Mar 21, 2006 IP
    SERPalert likes this.
  11. SERPalert

    SERPalert Guest

    Messages:
    1,003
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    0
    #11

    Genious! Thanks
     
    SERPalert, Mar 21, 2006 IP
  12. SERPalert

    SERPalert Guest

    Messages:
    1,003
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    0
    #12
    hmm using php how can I get the url in the address bar?

    
    $http_host = $_SERVER['HTTP_HOST'];
    $request_uri = $_SERVER['REQUEST_URI'];
    $current_url = "$http_host"."$request_uri";
    
    PHP:
     
    SERPalert, Mar 21, 2006 IP
  13. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #13
    That should be it I think. Does it not give the URL of the frameset?
     
    T0PS3O, Mar 21, 2006 IP
  14. SERPalert

    SERPalert Guest

    Messages:
    1,003
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Well it hasn't done what I expected it to do. I gave back MY url, not the url of the frameset.

    More testing needed maybe...
     
    SERPalert, Mar 21, 2006 IP
  15. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #15
    What about PHP_SELF?

    $url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    PHP:
     
    T0PS3O, Mar 21, 2006 IP