We help IT Professionals succeed at work.

Disable session.use_trans_id based on user agent

luxurylink asked
Last Modified: 2012-06-21
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?
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)

//put this at the top of your php doc
     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

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.


The virtual host solution would have worked, but instead we simply didn't start a session when being crawled.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.