Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Does not want to see PHPSESSID in the url. How can be done
this ?

Answer Posted / pankajbisane

1. In your config.php file, put the following code:

<?php

ini_set('session.use_trans_sid', 0);

ini_set(‘session.use_only_cookies’, 1);

?>

This will tell the server to overrule its current insecure
and SEO-unfriendly settings. Unfortunately, most shared
hosting companies don’t allow these modifications using
ini_set. Another method can be used.

2. In your .htaccess file, use the code below:

php_flag session.use_trans_sid off

php_flag session.use_only_cookies on

Place this file in the webroot of your website. It will have
the same result as method 1.

This should do the trick of preventing any ?PHPSESSID to any
new content. But, what to do if you already have webpages
listed in the search-engines with the ?PHPSESSID attached?
Use one of the solutions below:

1. Add the following code to the .htaccess file:

<IfModule mod_rewrite.c>

RewriteEngine On

#remove PHPSESSID

RewriteCond %{QUERY_STRING} PHPSESSID=.*$

RewriteRule .* %{REQUEST_URI}? [R=301,L]

</IfModule>

In order for this to work, the hosting company must have
their PHP compiled with mod_rewrite. If this isn’t the case,
another solution would work similarly

2. Add this code to your config.php file (retrieved from:
http://www.joostdevalk.nl/how-to-get-rid-of-phpsessid-in-the-url-and-redirect/)

<?php

if (isset($_GET['PHPSESSID']))

{

$requesturi =
preg_replace('/?PHPSESSID=[^&]+/',"",$_SERVER['REQUEST_URI']);

$requesturi = preg_replace('/&PHPSESSID=[^&]+/',"",$requesturi);

header("HTTP/1.1 301 Moved Permanently");

header("Location: http://".$_SERVER['HTTP_HOST'].$requesturi);

exit;

}

?>

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which function would you use to determine the length of a string in php?

977


I am writing an application in php that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with php?

887


Tell me what does the array operator '===' means?

1016


Explain different sorting function in php?

1009


What is http php?

901


Is it possible to extend the execution time of a php script?

915


What are the main error types in php?

1008


How to execute an sql query?

928


What does empty mean in php?

925


What is prepared statement in php?

1013


Why session timeout is important?

1054


What are default session time and path?

1053


Which programming language does php resemble to?

972


Which function is used to read a single character from a file in PHP.

995


How to find the length of a string?

906