PHP and XHTML Compliancy Trick

I like standards. It gives a good goal to code for whether it is in PHP, HTML, or XHTML. However, there are some pitfalls from time to time when using standards. On the server that Wyome.com is hosted on, I realized that session.use_trans_sid was set to on. What this means to me is that whenever I am using a form, PHP will insert a hidden field into the form to show the session id. Unfortunately, PHP inserts this outside the container which breaks XHTML Strict 1.0 compliancy which Xaraya works toward.

Another problem with using the use_trans_sid is Search Engines. Since the search engine bots crawl as an anonymous user, PHP will introduce a call to the session id for the bot in all of the URLs. This isn't the greatest thing in the world for those of you that are search engine optimization zealots. I don't want the links to Wyome appended with a session id any more than I want my XHTML compliancy broken. So what is a fellow to do?

I did a quick search on the issue and found a very useful tutorial on how to turn off the value with a .htaccess file. What I wanted to do is override the value in the php.ini without touching the core for Xaraya code. This meant that I needed to go with the .htaccess approach.

I was hesitant in overriding the value in the xarSession.php within the root of Xaraya because sessions are an area that can be flaky with PHP. What may work on one server, might not on another, and thus we are left with a support issue to deal with. Using the .htaccess method is much easier to work with on a case by case method, and allows the individual site to decide how best to deal with their issues.

Sources:

Why You Should Disable PHP's session use_trans_sid

ini_set function documentation

Xaraya

Print | Related