Navigation
Home

About Me

Links

Resume

Contact

Search






Categories


Archives


July 2011
February 2011
January 2011
December 2010
October 2010
August 2007
November 2006
June 2006
May 2006
April 2006
March 2006
February 2006
November 2005
October 2005
April 2005
December 2004

 

Syndicate this site (XML)

 

Validation

Valid XHTML

Valid CSS

 

Disclaimers

© Manish Singh

 


Archives

May 10, 2006

PHP Session IDs removal

This article deals with removing php session ids (PHPSESSID) from the URLs of your php applications. Assuming you are using apache web server with ReWrite Mod enabled, you can add the following piece of code in your .htaccess file


php_value session.use_only_cookies 1
php_value session.use_trans_sid 0


In order to redirect the URLs already indexed in search engines with the php session id ( PHPSESSID ) values add the following code in .htaccess file


Options +FollowSymlinks
RewriteEngine On

RewriteCond %{QUERY_STRING} ^PHPSESSID=.*$
RewriteRule .* %{REQUEST_URI}? [R=301,L]


It may happen that editing .htaccess file may not be possible for you or that it produces Internal Server Error (Error 500).

In such cases you can add the following piece of code in your php application itself to get rid of phpsessid


ini_set('url_rewriter.tags','');


There may be many other methods to remove php session ids from the URLs but these two work best for me.

Posted by manish at 11:49 AM | Comments (0)