We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13218
    • 134 Posts
    Hi,
    i just noticed that on the first visit to a modx-site the session id is appended automatically into each link.
    So, i never put any thought yet into session-management. But i just set my first cookie (whoopie) so i guess now i have to:
    as i understand it so far, in order to use cookies a session has to be started anyway, correct? And this session-appending is the way to start this? Now, first thing that comes to my mind is google et al - is this phpsessid affecting anyting? Or do they just dismiss it?

    Ok, i just looked at some sites from the ’made in modx’ and i didn’t find that on any of these sites. So probably again i just don’t get it. My question is: is this appending of the session_id mandatory and if not, can i change it to something less obstrusive? Or maybe just don’t know something very fundamental - in this case i’d be happy if you could give me a pointer where to get some comprehensive information on this.

    Thanks.
      @itWilllBeOK
      • 28215
      • 4,149 Posts
      MODx should most definitely not be appending your session ID to the URL...sounds like a server misconfiguration to me.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 13218
        • 134 Posts
        Thanks Shaun, it helps to know where not to look.
        I found that ’session.use_trans_sid’ in the server configuration seems to be responsible for this. With ’[tt]ini_set("session.use_trans_sid", "0")[/tt]’ via php i couldn’t change it but ’[tt]php_flag session.use_trans_sid off[/tt]’ in the htaccess did the trick. No more appending and cookies seem to be working still.
        Merci.
          @itWilllBeOK
          • 436 ☆ A M B ☆
          • 265 Posts
          I was just looking through my visitor stats and I noticed on everyone’s first visit something like this ?PHPSESSID=00681188c18dafee1e6999d4dd84a44d is being added to the end of every URL.

          I tried adding php_flag session.use_trans_sid off to the htaccess file but its not fixed the problem

          Any other ideas? Maybe a setting in Revo?
            MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
            • 10702
            • 107 Posts
              • 37054
              • 93 Posts
              The issue of PHPSESSID being appended to site URL's is not a trivial one - particularly from an SEO point of view it can lead to duplicate content issues with Google - I've written a blog post about ii which details the problem, shows how to prevent it and a fix for Google if you have already been indexed.

              PHPSESSID and ModX

              I think it would be worth adding the 2 lines mentioned in my post to the ht.access file supplied with ModX so that others don't run into this issue.

              Hope it helps.
                • 36509
                • 127 Posts
                FreelanceWebDev,

                I tried your fix and got this error:

                Parse error: syntax error, unexpected '<' in /home1/jbmaudio/public_html/core/cache/includes/elements/modplugin/9.include.cache.php on line 8


                My plugin is named: PHPSESSID-redirect
                The code is:
                //check we are acting on the right system event - in this case onWebPageInit
                switch($modx->event-<name){
                case 'onWebPageInit':
                //check if we have the PHPSESSID parameter in our querystring
                if (isset($_GET['PHPSESSID'])) {
                //if so, strip it out
                $requesturi = preg_replace('/&PHPSESSID=[^&]+/',"",$_SERVER['REQUEST_URI']);
                $requesturi = preg_replace('/PHPSESSID=[^&]+/',"",$requesturi); 
                $requesturi = preg_replace('/(\?)$/',"",$requesturi);
                 //give Google a 301 response so it knows this redirect to our clean url is permanent
                header("HTTP/1.1 301 Moved Permanently");
                //redirect to our clean URL
                 header("Location: http://".$_SERVER['HTTP_HOST'].$requesturi);
                 exit;
                }
                break;
                }


                and has a check mark on :

                OnWebPageInit

                any ideas?
                  www.JBMWebDesign.com
                  www.JBMAutomation.com
                  • 36509
                  • 127 Posts
                  switch($modx->event-<name){


                  This seems to be the line that is causing the error.

                  Any Ideas?
                    www.JBMWebDesign.com
                    www.JBMAutomation.com
                    • 37054
                    • 93 Posts
                    Should be

                    switch($modx->event->name){
                    


                    Have updated blog post to reflect correction. [ed. note: freelancewebdev last edited this post 14 years, 6 months ago.]
                      • 36509
                      • 127 Posts
                      Ok I don't get any error now, but it doesn't seem to work

                      http://jbmautomation.com/services.html?PHPSESSID=401a91ea3851b0cbc3a97da48c644b15

                      should go to

                      http://jbmautomation.com/services.html

                      correct?

                      it is not. It goes to the page with PHPSESSID.

                      Any suggestions?
                        www.JBMWebDesign.com
                        www.JBMAutomation.com