Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Removing session id from a url!
Old 01-04-2006, 02:43 PM Removing session id from a url!
Skilled Talker

Latest Blog Post:
New Operating System
Posts: 79
Trades: 0
Hey everyone, good to see you all

Ive been trying to remove the session id from a url so my crawler doesnt think theres an unlimite amount of pages but my code isnt working so well.
My code is:
PHP Code:
<?php //Session ID  removal //cant have same name
function remove_session_id($full_url) {
    
find_session();
}

function 
find_session() {
    global 
$linksarray;
    
    foreach(
$linksarray as $value) {
        
$array preg_split("[\?|\&amp;]",$value);

        foreach(
$array as $other_value) {
                
            
$get_array explode('=',$other_value); //Splits the $_GET name from the $_GET data
            
$search eregi('[abcdef0-9]',$get_array[1]); //Looks for $_GET information with 0-9 & A_F
                
            
if($search == true || $search === true) {
                echo(
'potential session id found/n');
            } else {
                break;
                return 
false;
            }
        }
    
var_dump($array); //debug*/
    
}
?>
Can anyone maybe help me? i need to remove a 32 long string full of 0-9 and a-f.

Thanks
__________________

Please login or register to view this content. Registration is FREE
WinSrev is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-04-2006, 03:17 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
If you want to actually remove the sid completely, you can do something like this:
PHP Code:
<?php
function find_session() {
    global 
$linksarray;
    
    foreach(
$linksarray as $key => $value) {
      
$str preg_replace('#sid=[abcdef0-9]{32}#',"",$value);
      
$str preg_replace('#(\?|\&(amp;)?)\&(amp;)?#',"\\1",$str);
      
$linksarray[$key] = preg_replace('#\?$#',"",$str);
    }
    


$linksarray = Array(
"http://www.something.com?sid=abd6e7f8c9e0adc9e7f8b9037dbe7293&amp;one=one&two=two",
"http://www.something.com?three=three&amp;sid=abd6e7f8c9e0adc9e7f8b9037dbe7293&amp;one=one&amp;two=two",
"http://www.something.com?sid=abd6e7f8c9e0adc9e7f8b9037dbe7293"
);
echo 
"<pre>";
print_r($linksarray);

find_session();

print_r($linksarray);
echo 
"</pre>";
?>
That code results in the output:
Code:
Array
(
    [0] => http://www.something.com?sid=abd6e7f8c9e0adc9e7f8b9037dbe7293&one=one&two=two
    [1] => http://www.something.com?three=three&sid=abd6e7f8c9e0adc9e7f8b9037dbe7293&one=one&two=two
    [2] => http://www.something.com?sid=abd6e7f8c9e0adc9e7f8b9037dbe7293
)
Array
(
    [0] => http://www.something.com?one=one&two=two
    [1] => http://www.something.com?three=three&one=one&two=two
    [2] => http://www.something.com
)
(My browser flattened the &amp s into plain & when rendered).
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 01-04-2006, 04:10 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
stick the following two lines in your .htaccess file
Code:
php_value session.use_only_cookies 1 
php_value session.use_trans_sid    0
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 01-04-2006, 04:19 PM
Skilled Talker

Latest Blog Post:
New Operating System
Posts: 79
Trades: 0
What? how will that help my crawler?
__________________

Please login or register to view this content. Registration is FREE
WinSrev is offline
Reply With Quote
View Public Profile
 
Old 01-04-2006, 04:28 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
Sorry, It's been a long day. I thought you wanted to remove the session ID's from your urls so they can be crawled. I didn't realize you were writing the crawler.

My apologies
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 01-04-2006, 07:35 PM
Skilled Talker

Latest Blog Post:
New Operating System
Posts: 79
Trades: 0
Thanks everyone, it now removes session id's
__________________

Please login or register to view this content. Registration is FREE
WinSrev is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Removing session id from a url!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30790 seconds with 12 queries