Keep Session Id Out of URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
idotcom
Forum Commoner
Posts: 69
Joined: Thu Mar 04, 2004 9:24 pm

Keep Session Id Out of URL

Post by idotcom »

Hi

How do I keep my session id's out of urls when bots come to my site?

Every time a robot comes to spider my site, the are given urls with the PHPSESSIONID=VALE

I'm sick of it. It appends to every url. And all my SERPS have stupid session id's in them. :?


I'd greatly appreciate a solution to this. :D

Thank you
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

session.use_trans_sid = 0
idotcom
Forum Commoner
Posts: 69
Joined: Thu Mar 04, 2004 9:24 pm

Post by idotcom »

Hi

Thanks for youre reply.

I tried:

Code: Select all

ini_set("url_rewriter.tags","");
ini_set("session.use_trans_sid", false);
And just a little bit ago msnbot came and still had session id in the url.

This is annoying... why would PHP allow this?

Any other ideas?


Thanks
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

You can turn it off in an .htaccess file. I don't know the syntax offhand.
eyespark
Forum Commoner
Posts: 50
Joined: Tue Jan 24, 2006 7:36 am

Post by eyespark »

htaccess

php_flag session.use_trans_sid off
idotcom
Forum Commoner
Posts: 69
Joined: Thu Mar 04, 2004 9:24 pm

Post by idotcom »

Thanks,

I tried that in htaccess too.

I emailed my host because everything I tried did not work.

I even tried this in htaccess: php_value session.use_trans_sid 0
Gambler
Forum Contributor
Posts: 246
Joined: Thu Dec 08, 2005 7:10 pm

Post by Gambler »

I rcommend writing your own session handling functions (if that's an option). It much easier that dealing with the ones that are provided by PHP.

Example:
http://cvs.sourceforge.net/viewcvs.py/n ... iew=markup
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

idotcom wrote:Hi

Thanks for youre reply.

I tried:

Code: Select all

ini_set("url_rewriter.tags","");
ini_set("session.use_trans_sid", false);
And just a little bit ago msnbot came and still had session id in the url.

This is annoying... why would PHP allow this?

Any other ideas?


Thanks
You have to make sure the ini_set("session.use_trans_sid", false); is before the session_start();. If it isn't then you will still get the session ids in the url.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

"you need to enable session.use_only_cookies. In that case, cookies must be enabled unconditionally on the user side, or sessions will not work."
http://us3.php.net/session
Post Reply