We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15987
    • 786 Posts
    I am trying to setup a login to an smf forum on pages outside of the forum. To do this I am using the smf ssi function ssi_login(). When I use the login form it creates, it sends me to the forum start page and logs me in. But I would like it to keep the user on the current page they are logging in from. In the ssi docs it says to pass in the link to have it redirect to where you want. So I created the following snippet to try and get this done:

    include_once("forums/SSI.php");
    
    $curId = $modx->documentIdentifier;
    $currentPageLink = $modx->makeURL($curId);
    
    if($user_info['is_guest']) {
        ssi_login($currentPageLink);
    } else {
        //User info
        ssi_welcome();
        echo '<br /><br />';
        ssi_logout($currentPageLink);
    }
    


    This still takes me straight to the main forum page after logging in though. I tried hard coding the page into the function call and that didn’t work either. The one thing I did find in the smf forum was to set $_SESSION[’login_url’] equal to the page link, but that did not work either. After looking some more around the smf forums I have not been able to find any clues on how to fix this and was wondering if anyone had this working with modx. I also get the following error when I click the logout link on my test page:

    Session verification failed. Please try logging out and back in again, and then try again.

    I have tried many of the other functions and they work, and the login works just not with the redirect. So I’m not sure if it may be a something in modx or in smf that is keeping me from using these.

    I am going to try to find some more info over on the smf site but thought I would post it here incase anyone had a like experience.

    Kyle

    I am using modx .9.2.1 and smf 1.1RC2
      • 37272
      • 216 Posts
      Hiya Kyle,

      It seems that you’ce had related problems to myself and Garry. Did you manage to resolve this?

      http://modxcms.com/forums/index.php/topic,4074.0.html

      The code provided in the above thread works great, except when you use SSI calls that rely upon cookies or sessions. sad
        • 15987
        • 786 Posts
        I have not had a chance to get back to this, and have not solved the problem. If you have any ideas on how to get it working that would be great.
          • 37272
          • 216 Posts
          No, I haven’t. It appears to be a session problem, but you already know that. I wondered if it was mistake with caching, but no. I’ve created alternative snippets, combining calls, etc. (shot-in-dark stuff), to no avail.

          This seems to be quite a fundamental problem, and needs to be sorted out; but I would say that, wouldn’t I? grin But since Modx has decided to to go for quite close integration with SMF, it is something that should be sorted out. Unfortunately, I’m just not the guy to do it. sad
            • 28224
            • 17 Posts
            Same problem! Using the SSI code on a non-Modx page works fine, so something in Modx must be interfering with this. Just noticed as well that the non-Modx page shows a different session in the logout link than is shown when trying to do this within Mod-x, therefore it would appear that sessions are getting confused and that this is being caused by something within Modx.

            It seems that a large number of people have had or are having this problem - has anyone got a solution?
              • 22303 MODX Staff
              • 10,725 Posts
              MODx and SMF have there own ways of managing sessions, and they are not compatible. This is not a flaw of MODx, or SMF, but of the general model of authentication and session handling in PHP applications. In Java/J2EE for instance, applications run within an application server and can choose to share authentication and session resources with other applications running on that server through a common API. No (standard) API exists in PHP for this, and thus you have the challenge of modifying any scripts you want to integrate at this level.

              We use the SSI stuff, slightly modified, but only in limited ways because of this problem.

              Quote from: Colin at Aug 31, 2006, 03:29 PM

              This seems to be quite a fundamental problem, and needs to be sorted out; but I would say that, wouldn’t I? grin But since Modx has decided to to go for quite close integration with SMF, it is something that should be sorted out. Unfortunately, I’m just not the guy to do it. sad
              I would call this a fundamental problem in PHP applications in general, and I don’t think "MODx" ever decided to go for close integration with SMF; it’s just what we used and what was convenient at the time the SMF Bridge was built by the founder of MODx. I’d love to see a solution to this as well, but the reality is more complex than it may seem at first.
                • 28224
                • 17 Posts
                Thanks for the lightning fast response. smiley

                I like Modx so far and would like to stick with it. I do, however, need a forum. SMF provides all the functionality that I need and I would therefore be happy for it to provide all member related functions. It would seem that the Modx session is over-riding the one that SMF needs to use as far as I can tell. If this is the case then I would expect to either stop Modx from having anything to do with setting sessions, cookies, etc or make SMF use the Modx sessions table (assuming that there is one) for session authentication? Are these possibilities?

                You stated that you use the SSI stuff slightly modified. Can you share what you have? I simply want users to be able to use the login/logout functionality from all pages in the site and not just from the forum section.

                Finally, if SMF simply cannot be easily used with Modx at present are there any forums that can easily be integrated?

                Thanks for your help OpenGeek!
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 28224
                    • 17 Posts
                    Thanks Sottwell. I have tried SMFssi and, whilst it brings the items such as ssi_welcome, ssi_login, etc, to the page, they do not work correctly. For example, I am unable to specify a redirect url on login and the logout link does not work at all due to some problem with the wrong session id being specified in the logout url.

                    With regard to SMF Forum Integration, I simply cannot get this to work in any satisfactory way. sad
                      • 22303 MODX Staff
                      • 10,725 Posts
                      Quote from: spooky at Nov 22, 2007, 09:40 AM

                      I like Modx so far and would like to stick with it. I do, however, need a forum. SMF provides all the functionality that I need and I would therefore be happy for it to provide all member related functions. It would seem that the Modx session is over-riding the one that SMF needs to use as far as I can tell. If this is the case then I would expect to either stop Modx from having anything to do with setting sessions, cookies, etc or make SMF use the Modx sessions table (assuming that there is one) for session authentication? Are these possibilities?
                      MODx will not work without sessions, nor will any secured PHP web application. What you need is a centralized user repository which both systems can use as their user base (i.e. LDAP, OpenID, or some other centralized authentication directory), then supplement with their own data (application-specific permissions and session handling). Since PHP does not provide this centralized service, each application must be made to work with it in some way. It’s a complex problem, and one that I deal with in a different way based on client project requirements. I sure do miss the common security architecture available in J2EE application servers...

                      Quote from: spooky at Nov 22, 2007, 09:40 AM

                      Finally, if SMF simply cannot be easily used with Modx at present are there any forums that can easily be integrated?
                      Same issue; again, it’s a fundamental problem with PHP user management and security. We are working on some potential solutions to better address this in future releases, but unfortunately, each application presents it’s own challenges, depending on how it was implemented.