Link to home
Start Free TrialLog in
Avatar of luxurylink
luxurylink

asked on

Disable session.use_trans_id based on user agent

We're in the process of making our site search engine friendly.  We were told not to append PHPSESSID to our links.  So what we want to do is disable session.use_trans_id when we are being crawled by google for example.  We are using PHP 4.3, which doesn't allow this configuration setting to be changed by using the function ini_set().  Adding php_flag sesssion.use_trans_id 0 in .htaccess works, but we need this directive to only be read in based on the user agent.  I can successfully set an env variable in .htaccess, but can't use it as the value for  sesssion.use_trans_id.  Is there any other way to achieve what we're trying to do?
ASKER CERTIFIED SOLUTION
Avatar of TeRReF
TeRReF
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of neorush
neorush

<?PHP
//put this at the top of your php doc
if(eregi("googlebot",$_SERVER["HTTP_USER_AGENT"])){
     ini_set('session.use_trans_sid', 0);
}

?>

I should point out that this is technically against Google's policy.  You shouldn't alter your site data for Google in anyway.  But  for all real world purposes this should be fine.

There is also the global .htaccess way :
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>
Like luxurylink said, ini_set('session.use_trans_sid', 0); does not work in PHP 4.
From what I understand from his question, .htaccess is not an option either at this point.
Avatar of luxurylink

ASKER

The virtual host solution would have worked, but instead we simply didn't start a session when being crawled.