1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Session id detection

Discussion in 'Programming' started by sarahk, Apr 28, 2004.

  1. #1
    I'm looking through some page data and want to eliminate sessions from the variables passed in a url.

    I have no way of knowing what the session name will be - it could be sessid, cs, sid, etc. I'm using a standard test of 32 or 82 chars but one of the sites sending me data has variable length session ids.

    Is there a standard way to detect this?

    examples:
     cs= 
    cs=127bd94c883ffd499bca95c324
    c%2F%2F%2F
    cs=5433cd98e6d
    
    Code (markup):
    The easy workaround is trim off the query string but they are often valuable data.
    SEMrush
     
    sarahk, Apr 28, 2004 IP
    SEMrush
  2. er2er

    er2er Peon

    Messages:
    9
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In PHP, this should work:
    preg_replace("/cs=[^&]*&?/i",'', $url);
    PHP:
    where $url contains the url.
     
    er2er, Apr 28, 2004 IP
  3. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,284
    Likes Received:
    2,600
    Best Answers:
    460
    Trophy Points:
    710
    Digital Goods:
    29
    #3
    Why are the session IDs named differently? Can't you change them to be consistent?

    - Shawn
     
    digitalpoint, Apr 28, 2004 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    25,341
    Likes Received:
    3,481
    Best Answers:
    101
    Trophy Points:
    665
    #4
    If only!

    I'm taking data from other sites and I don't want to have to vet them as they come, although I guess I could get them to say how they id sessions - but in the example given they may not even be aware that the session info gets produced for some bots.

    I flag the urls which have session info attached and hopefully site owners will use that info to make alternative arrangements for when bots visit. But like the bots I don't want to create a record for every page and session id combination.

    I think, Shawn, you've just given me my workaround. I'll store the session id string against the domain - as that will be consistent within the domain.


    Thanks er2er but I think this relies on the consistent session name.
     
    sarahk, Apr 28, 2004 IP
  5. er2er

    er2er Peon

    Messages:
    9
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, it does - I assumed this was what you wanted.
    What about:
    preg_replace("/(cs|sessionid|sid|sesid)=[^&]*&?/i",'', $url);
    PHP:
    It can be easily extended by adding more names to "(cs|sessionid|sid|sesid)"

    However, storing what id_name belongs to what domain looks as a beter idea to me :)
     
    er2er, Apr 29, 2004 IP