We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8894
    • 114 Posts
    Hello everybody,

    I started a rewrite of WebLogin snippet to best fit my needs.
    But I’ve got a problem with the redirect functionality : it works fine with Firefox (version 2.0.0.9), but with IE7, it goes to the new page and then goes back to previous page.
    It seems to be linked with REDIRECT_HEADER parameter of $modx->sendRedirect() : when I replace it with REDIRECT_REFRESH, the redirect works, but you can see previous page before refresh and that’s why I wanted to use REDIRECT_HEADER.

    I made a class, which main method is :
    function process()
    {
        switch ($_REQUEST['action']) {
        case 'login':
            $this->login();
            if ($this->isLoggedIn()) {
                $pageId = $this->getHomePage($this->config['loginHomeId']);
                $this->redirectToHomePage($pageId);
            }
            break;
        case 'logout':
            $this->logout();
            $pageId = $this->getHomePage($this->config['logoutHomeId']);
            $this->redirectToHomePage($pageId);
            break;
        default :
            break;
        }
    
        $this->setPlaceHolders();
        if ($this->isLoggedIn()) {
            return $this->config['loggedTpl'];
        }
        else {
            return $this->config['notLoggedTpl'];
        }
    }
    


    The redirect method is :
    function redirectToHomePage($homeId)
    {
    		global $modx;
    		
        $url = $modx->makeUrl($homeId);
        if ($homeId == $modx->documentIdentifier) {
            $modx->sendRedirect($url, 0, 'REDIRECT_REFRESH');
        }
        else {
            $modx->sendRedirect($url, 0, 'REDIRECT_HEADER');
        }
    }
    


    On my login page (id=12), I’ve got this snippet call :
    [!SimpleWebLogin? &loginHomeId=`4` &logoutHomeId=`1`!]


    I also attach a zip with the whole snippet files.

    Can you help me ?

      • 8894
      • 114 Posts
      I found it : it is because I had 2 calls of my snippet within the same page and with different parameters.