Home > PHP >
Why You Should Disable PHP's session use_trans_sid | Sitemap Search |
|
Sections Membership Features
Recent comments
very difficult by alfin Taking the credit for another persons work ? by curious dude. |
Why You Should Disable PHP's session use_trans_sidPosted by martin on 1 Jun 2002, last updated on 10 Sep 2002. PHP will add a unique PHPSESSID query pair to URIs within your site if cookies are not available and session.use_trans_sid is set. While this helps people who do not accept cookies, search engines will rank your site low. Why should I careWith the release of PHP version 4.2.0 you don't need to configure PHP with Without this feature you can usually choose between sending cookies to the visitor and modifying the URLs, with cookies being the default setting. Cookies do no harm (most of the time) but appending a query string to all URLs is quite different. Search enginesWhen search engines crawl your site usually they won't remember sent cookies so PHP will modify the links for them. As a result of that the links to your site at Google will always have a query string with the session attached to them, besides the fact that they will look bad search engines will crawl less of your site and you don't want that with search engines being the most popular way for people to find a site. What's more they may even consider your site as mirroring itself when they got different sessions appended. This looks to search engines as if different pages have exactly the same content, and they will lower your rank or even ban it. XHTML 1.0 Strict or XHTML 1.1 validationIf you have forms and have left the default settings for the rewritable tags PHP will also add a hidden input to forms on your site but does that in such a way that your code cannot validate as XHTML 1.0 Strict or XHTML 1.1. How do I deal with thatYou can disable that feature via a For a php_flag session.use_trans_sid off And in PHP code:
ini_set('session.use_trans_sid', false);
Commentsmask , PHPSESSID by lolik (lolikk@barak-online.net) on 26 Dec 2002 7:10pm GMT hi when i enter to the site dietnow.run.to that is configured to target www.top-diet.com?index.php?sid=2000 with mask cloaking on the url it go into the targrt url ok but adds index.php?PHPSESSID=67723jkdfjkasjr8f98j and distroy my session!!! how do i fix it when i still want to use the mask cloaking? 10x PHPSESSID hidden field automaticinseted into forms by iso (email@isomorphicnet.com) on 16 Feb 2003 3:41pm GMT remeber to call ini_set('session.use_trans_sid', false); before session_start(); www.isomorphicnet.com making links absolute rather then relative by Steve () on 1 May 2003 7:37pm GMT I've done the ini_set on my site, but it still seems to place the sessionid in the url for relative links -- say [a href="/page.php"], it will still change it even when I reset the trans_sid to false (before the session_start()).. So, I've made them absolute links and this seemed to resolve the issue.. turn url_rewriter.tags off by Martin () on 26 May 2003 2:55pm GMT ini_set('session.use_trans_sid', false); won't help, but ini_set("url_rewriter.tags",""); does Forget everything but htaccess by jfmsimplecomplex on 15 Sep 2003 9:36pm GMT <IfModule mod_php4.c> php_flag session.use_trans_sid off </IfModule> This page (and Martin Tsachev) saved my day, or rather my week. I've been working pretty hard to get those damned sessionids out of the url. The versions of PHP-environments I currently work in are 4.3.2 and 4.3.3. No matter what the manuals say, the ini_sets session.use_only_cookies and session.use_trans_sid have failed. And url_rewriter.tags simply disables session-starting at all. Before these endeavours I spend some time contructing complicated sequences of header- and refresh-redirects, until I picked up that the session simply dies during a redirect (unless you write ?PHPSESSID=$PHPSESSID into the executing urls, obviously getting nowhere in the attempts to get rid of the sh..). But the .htaccess-expression does the trick. Hooray! Thanks jfmsimplecomplex by Happy Hunter () on 16 Oct 2003 11:53am GMT That was exactly what i needed to see. I wasn't sure how to write it in the .htaccess file. You couldn't have made it clearer. Hooray Indeed :) PHP session IDs and google by Astronaut Pete () on 20 Oct 2003 9:32pm GMT I finished developing my site before fully understanding the google-monster. I was really worried about turning my SESSION IDs off in case my real customers had dropped sessions, or didn't have cookies enabled. So.... I am trying the following in an attempt to get google and the only other webcrawler on my site to have a good root round by turning the URL rewriter tags only for these user agents. I've done this by checking the HTTP_USER_AGENT as follows BEFORE any session_start() command: if(strpos($_SERVER['HTTP_USER_AGENT'],"google")!==false or strpos($_SERVER['HTTP_USER_AGENT'],"MSIECrawler")!==false) { ini_set("url_rewriter.tags",""); } Hope this is of use to those folks stuck up the same tree I was, Astronaut Pete PS how about making the add comments box a bit bigger???!! What about IIS Servers? by Steve (stevefree@yahoo.com) on 6 Nov 2003 9:57pm GMT IIS does not use a .htaccess file. What do we do for this? Turn this off in php altogether... by Liquibyte () on 4 Dec 2003 8:30am GMT Find 'session.use_trans_sid' in your php.ini file and make sure it's set to 0, i.e. 'session.use_trans_sid = 0'. This is off by default in PHP Version 4.3.4, I don't know about other versions, sorry. php sessions & search engines by mark thurston (mav1245@aol.com) on 4 Dec 2003 9:48pm GMT or you could just use the user agent string with get_browser(); to exclude search engines from being assigned any of the session features. this could be a better approach as then anyone using non-cookie enabled browsers will still be able to enjoy your site and buy your products runtime control of trans_sid by Peter () on 16 Jan 2004 12:35am GMT Using ini_set('session.use_trans_sid', false); will NOT work if you are using PHP as a compiled-in module to Apache (and possibly other servers). BUT(!) Martin and Astronaut Pete are correct in suggesting ini_set("url_rewriter.tags",""); because that is a RUNTIME modifiable string. This allows trans_sid to do its thing, but it doesn't have any "thing" to do. Result: runtime control of trans_sid for people using complied in PHP modules. IMODE Programming by Malik Muhammad Younus Awan (younus@iuj.ac.jp) on 7 Feb 2004 8:08pm GMT Hi, i am developing a shoping site for imode enabled mobile phones using php. as for as i know not all imode browsers support cookies. what should i do in order to use session and is there any suggestions for making this website more secure? thank you in advance PHP v4.3.3R1 by casa (casa3311@hotmail.com) on 25 Mar 2004 1:17pm GMT We recently upgraded to PHP V.4.3.3R1 and now, I have an intermittent problem of sessions not being carried between pages. I checked info.php and session.use_trans_sid is set to off. I have been told that if it is set to on, my sessions session problem will go away. I do have session_start(); at the top of each page. If anyone could tell me if this is true or not, please email me at casa3311@hotmail.com Doesn't work by Dalibor Kezele (dalibor42@yahoo.com) on 27 Apr 2004 1:50pm GMT When I turn off session.use_trans_sid PHPSESSIONID is gone but I am left without sessions too. What else should be done in order to have session control back? (PHP4.3+, Apache) TIA, dalibor42@dalibor42.f2o.org help by dejen (dejenalemu0@yahoo.com) on 28 Apr 2004 4:38pm GMT i am developing a shopping site for mega enterprise using php. I try to use session to secure the site through login to order products. The php code is <?php 'session.use_trans_sid = 0'. session_start(); include 'connect.php'; $username = $_POST['username']; $password = $_POST['password']; if((!$username) || (!$password)){ echo "Please enter ALL of the information! <br />"; include 'logina.html'; exit();} $password = md5($password); $sql = mysql_query("SELECT * FROM account WHERE username='$username' AND password='$password' AND activated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)) { foreach( $row AS $key => $val ) { $$key = stripslashes( $val ); } session_register('username'); $_SESSION['username'] = $username; include 'admina.html'; } }else { echo "You could not be logged in! Either the username or password do not match!<br /> Please try again!<br />"; include 'logina.html';} ?> But when I try to login it retrieve the following warnings. Warning: open(/tmp\sess_2adc3442630a9af3dfcd2293676d623a, O_RDWR) failed: No such file or directory (2) in c:\program files\apache group\apache\htdocs\mega\lo.php on line 3 Warning: open(/tmp\sess_2adc3442630a9af3dfcd2293676d623a, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 Please help me to correct the above warning.thank you. hth by myshpa () on 3 May 2004 12:47pm GMT create directory [drive]:\tmp first [drive] should be the drive you've got your files on YOU...................... by richiebman () on 24 May 2004 1:05pm GMT ............BEAUTY!!!!!!!! I will recommend this page to everyone I know (who also has PHP session problems). What is the correct syntax? by aleks () on 19 Jun 2004 9:15am GMT php_flag session.use_trans_sid false php_flag session.use_trans_sid off php_flag session.use_trans_sid "0" help by eng ghee (eg.chua@st.com) on 25 Jun 2004 2:28am GMT Hi All, I'm currently running my php script on linux server. I have the similar problem as "dejen" mentioned above. It there any posibilty to change "session_save_path=/tmp" to window environment (client) "session_save_path="c:\tmp" Please advisse me if any mistake that I mentioned above. Thanks! sess by jsbb0 (jabb0@jabb0.co.uk) on 27 Jun 2004 10:15pm GMT Can i disable use_trans_sid, and work with cookies disabled at the same time? Session id by Alex (zoonalex@hotmail.com) on 14 Jul 2004 10:37pm GMT How can I pass a session ID to a page without using cookies? I know that I can pass it through the URL, but how can I prevent other to see it in the URL?. Another solution for XHTML by Laurens Holst (laurensh1@yahoo.com) on 28 Jul 2004 9:13pm GMT As far as XHTML validation is concerned, another nice solution with the added advantage that it doesn't disable the trans_sid functionality itself is: ini_set('arg_separator.input','&'); ini_set('arg_separator.output','&'); It simply changes the invalidating ampersant from & to &, solving the problem! This is also a good solution if ini_set('session.use_trans_sid','0') doesn't work but you don't want to/can't temper with .htaccess files. ~Grauw Session id in forms by Rob () on 14 Aug 2004 4:47pm GMT I do want session ID to work in the members only section of my site, and want to pass the ID through an html form. I use ?session_name=session_ID. at the end of URLs, but what should I put in the Form? Thanks Session id in forms by Gareth (gareth@save9.com) on 6 Oct 2004 12:19pm GMT put <input type="hidden" and name = "session_name" and value = "<? echo $session_Id; ?>"> something like that This is just not working for me... by Marco Almeida (marcoalmeida@ptdivx.com) on 9 Oct 2004 12:41pm GMT I have this in the first lines of my php code: //Session ID should not be added to URL's ini_set('session.use_trans_sid', false); ini_set("url_rewriter.tags",""); My .htaccess file is: php_flag session.use_trans_sid off IndexIgnore * And it just doesn't work... At my home test server it does, but in the production server it doesn't... Production server phpinfo: http://www.websitefacil.com/info.php php session with client re-direction by chami (chamikara@yahoo.com) on 23 Nov 2004 10:54am GMT Hi, I'm trying to use php session in my site. It works fine when I re-direct pages from server side (require). But if if re-redirect to a page from clint side (using javascript) next page cannont access my session variables!! can any one help me pls.. chami um.. by Cody Mays (crxgames@gmail.no-spammage.com) on 30 Nov 2004 11:44am GMT The guy with the shop system needs to do something for security on that login... PHPSESSID and Google not a problem? by Nick Humphrey (nick@websynergy.no) on 2 Dec 2004 8:24pm GMT I don't think this is a problem any more with Google. Google doesn't show the sessid in their serps although the actual link still contains it. I came across many pages with decent PageRank which had a sessid. ref.: http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=deskbar&q=inurl%3Aphpsessid The one think i'm unsure of is maybe the pages i looked at are doing something special that i don't know about..testing to see if the user is a googlebot, for example, AND another thing actually is i am not sure if it affects how deep google crawls their site. Someone could test that by running site: on a particular site and their running a link tester (w/ their permission) and comparing the total links from the link tester with google's site: value. Session change & and dont go through pages by Giancarlo () on 13 Dec 2004 6:13pm GMT Hi, I am relative new to php. I was learning php about a month. I have a problem with the sessions that I guess is something in my php.ini, but I am not sure. I have APACHE-PHP-MYSQL server, and I upgrade to PHP 5.02 trying to get the sessions work, but was futile. I try this code: <?php session_start(); //session_register('contador'); session_name('misesion'); printf ("Actual Session is: ".session_id()."<br>"); echo '<a href="'.$PHP_SELF.'?'.SID.'">Counter SID is: '.++$_SESSION['contador'].'</a><br>'; echo '<a href="'.$PHP_SELF.'?'.$PHPSESSID.'">Counter PHPSESSID is: '.++$_SESSION['contador']. '</a><br>'; echo 'Session name is '.session_name().' and the session '.$_REQUEST[misesion].'<br>'; echo '<a href="sesion2.php?SID">With SID</a><br>'; echo '<a href="sesion2.php?$PHPSESSID">With PHPSESSID</a><br>'; ?> With the Counter SID the session goes normally, with the Counter PHPSESSID, the session resets each time. Dont get it. Then, never gives me $_REQUEST[misesion] (I change to $misesion and $_SESSION[misesion]) and nothing. But the real problem is that when I send to sesion2.php the session_id() shows me that a new session open, with SID or PHPSESSID. In that way I cant maintain the sesion through pages, what can I do or what I am doing wrong? Other thing, is that when I hit the Counter SID, my url appears like this: http://localhost/pruebas/sesion.php?PHPSESSID=61ca9c60b10cc8f481ac9c1eacbee797 Is any way to hide the session number from there too? ini_set('session.use_trans_sid', false); by nathan stiles () on 23 Dec 2004 8:33am GMT if my version is later than 4.2 will ini_set('session.use_trans_sid', false); actually change anything? http://www.blog-buster.net by Scribacchino (Scribacchino@hotmail.com) on 17 Jan 2005 10:24am GMT Ciao amici miei! sono http://www.blog-buster.net Ini set by Tom () on 17 Jan 2005 8:09pm GMT Ok thanks for pointing <i>that</i> out! added to my php.ini myshpa () by Evelyn (evemeseguer@cantv.net) on 28 Jan 2005 8:42am GMT I don't speak English, but thank you !!!!!!! myshpa () by Evelyn (evemeseguer@cantv.net) on 28 Jan 2005 8:46am GMT I have not slept in days looking for that instruction and it was here, thanks |