Googlebot, PHP, Sessions and URLs

Phew, thats a bit of a mouthful for a page title. Chances are if you´ve come accross this from a search engine you´re trying to figure out how to make a session enabled site more search engine friendly.

 
I´m just about to do this as I´m about to start on a new project with an ecommerce section (I actually started it about a year ago for Premier Computers but got…. sidetracked). The generally accepted and most reliable way of doing a shopping cart in PHP is to use sessions to store the users information such as basket items in a session array and then simply track them using the session ID.
 
This is fine when the user has cookies enabled as the variable is stored there. This is the case for over 90% (don´t email me with 100s of statistics – I don´t care) of users. As for the others, well in most server default setups the server will tack on the session ID to the end of all URLs if cookies aren´t being accepted. This is fine as it means this people can still use the site. The problem comes with bots that won´t accept cookies and therefore have the session ID in the URL of all your sites pages. In technical terms, this is "bad", as some won´t follow and the others that do rate the page as temporary or secure.

 
Luckily if its that important you can alter the settings to turn off this behaviour. You can either change php.ini or if you´re on Apache, you can put this in a .htaccess file in the site root:
"php_flag session.use_trans_sid Off"
"php_flag session.use_only_cookies On".
 
Gonna have a play around and set up some temporary page setups and see whcih googlebot likes the most. I´ll get back to you with what I find out.

About the Author

I'm a web developer based in the East Midlands, UK and if I keep up the current rate, I might have developed 3 million sites by the time I retire