Phpsessid Appending To Urls

admin

Administrator
Staff member
Hey guys<br /><br />I have done quite a bit of looking around on google to try and solve this issue I am having with one of my sites that im developing. It is written in PHP and dynamically creates links to the 3 newest news articles so the user can read the article in full, as on the main page only a short description of each article is displayed.<br /><br />For some reason though the PHPSESSID keeps getting appended to the end of these links, but to no others. This results in my site failing its W3C validation, which is something I really don't want to happen.<br /><br />As I said, all my other links don't get the ID appended to the end but these 3 links do.<br /><br />news.php?ID=13&PHPSESSID=0fe9e55786ed4e3dd36e682edd0554 is an example of what is happening.<br /><br />There is nothing written into my code which should do this so I imagine it is in fact a server related issue??? I don't really know to be honest.<br /><br />I read somewhere to create a .htaccess file with the following lines in:<br /><br /># php_value session.use_only_cookies 1 <br /># php_value session.use_trans_sid 0 <br /><br />I tried that, and nothing at all seemed to happen??<br /><br />Other than this little error on the front page, my entire site is W3C compliant and I would really like to get over this little hurdle if anyone knows how??<br /><br />Here's the code where I display the short description and article title, author and posted date as well as the link to the main article:<br /><br />This is all in a for loop which runs through the latest 3 articles in the database:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> <div class="newstitle"><br />                    <?php  <br />                                        // Print out the title<br />                    echo $newsdetails[$i][1];<br />                    ?><br />                    </div><br />                    <div class="newsbody"><br />                    <?php<br />                                        // Print out the short description of the article<br />                    echo $newsdetails[$i][2];<br />                    echo "<br/>";<br />                    ?><br />                    <br />                    <?php<br />                                        // Print out the read more link with the dynamically created URL<br />                    echo "<a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/\"news.php?ID=" .$newsdetails[$i][0]."\"><b>Read more...</b></a>";<br />                    echo "<br/>";<br />                    ?></div><br />                    <div class="newsauthor"><br />                    <?php]<br />                                        // Print out the author and posted date<br />                    echo "Posted by <b>".$authorname. "</b>";<br />                    echo " on ".$newsdetails[$i][4];<br />                    ?> </div> <?php<br />                    echo "<br/><br/>";<!--c2--></div><!--ec2--><br /><br />Any help would be spectacular.<!--content-->
I think I have solved the problem now...<br /><br />I removed the hashes (#) from the .htaccess file lines and now it works fine... I guess those were comments.<!--content-->
That's correct, the # hashes are how you comment in the .htaccess file.<!--content-->
Cheers bruce!!!<br /><br />Could anyone explain why this was happening because despite solving the problem I still don't fully understand why it did what it did!<!--content-->
Sorry, can't help you there. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /><br /><br />Maybe someone more familiar with PHP will be able to answer.<!--content-->
 
Top