[FAQ] Turning trans sid on or off (Was Turning off PHPSESSID)

[FAQ] Turning trans sid on or off (Was Turning off PHPSESSID)

Post by R. Rajesh » Fri, 25 Mar 2005 03:52:42


Q: When using session all the links are appended with PHPSESSID. How to
avoid that?
Q: How should I turn on or off the trans sid support?

A: when the "session.use_trans_sid" setting in php.ini is enabled, PHP
will append the session id in all relative links of the webpage. trans
sid feature helps to propagate the session id even if the browser
cookie is disabled.
To turn on or off:
1. Edit the php.ini file
2. Edit .htaccess file and set the PHP value (if you don't have
access to php.ini). This will work only in mod_php
3. Use ini_set() function < http://www.yqcomputer.com/ ; in the script
and enable/disable this feature.

Caveats:
(3) will work only in PHP 5; previous versions don't allow to change
via ini_set(). To enable/disable this feature via script, you have to
use other hacks.
To enable:
Add the following lines in the beginning of your script:
session_start();
output_add_rewrite_var(session_name(), session_id());
To disable:
Add the following lines in the beginning of your script:
session_start();
output_reset_rewrite_vars();

or add the following lines:
ini_set('url_rewriter.tags', '');
session_start();

Refer:
http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/

++++
@todo More info on htaccess trick. Or should find a separate question
on the ini settings.