We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33175
    • 711 Posts
    Hi all,

    I applied the patch ieButtonFix as KyleJ’s suggestion and I modified the function SessionHandler(). So, my cache problem is solved.

    Find function SessionHandler() approx the line 2200 and replace this function by
    	function SessionHandler($directive)
    	{
    		global $modx;
    				
    		if (!empty($this->Report))
    		{
    			return; //There was an error in the last step
    		}
    		
    		$cookieName = 'WebLoginPE';
    		
    		if ($directive == 'start') 
    		{
    			$_SESSION['webShortname'] = $this->Username; 
    		    $_SESSION['webFullname'] = $this->User['fullname']; 
    		    $_SESSION['webEmail'] = $this->User['email']; 
    		    $_SESSION['webValidated'] = 1; 
    		    $_SESSION['webInternalKey'] = $this->User['internalKey']; 
    		    $_SESSION['webValid'] = base64_encode($this->Password); 
    		    $_SESSION['webUser'] = base64_encode($this->Username); 
    		    $_SESSION['webFailedlogins'] = $this->User['failedlogincount']; 
    		    $_SESSION['webLastlogin'] = $this->User['lastlogin']; 
    		    $_SESSION['webnrlogins'] = $this->User['logincount'];
    		    $_SESSION['webUserGroupNames'] = ''; // reset user group names
    			
    			$cookieValue = md5($this->User['username']).'|'.$this->User['password'];
    			
    			if ($_POST['rememberme'] == 'on')
    			{
    				$cookieExpires = time() + (60 * 60 * 24 * 365 * 5); //5 years
    				
    				setcookie($cookieName, $cookieValue, $cookieExpires, '/', $_SERVER['SERVER_NAME'], 0);
    		    }
    			
    			if (isset($_POST['stayloggedin']) && $_POST['stayloggedin'] !== '')
    			{
    				$cookieExpires = time() + $_POST['stayloggedin'];
    				
    				setcookie($cookieName, $cookieValue, $cookieExpires, '/', $_SERVER['SERVER_NAME'], 0);
    			}
    		}
    		
    		if ($directive == 'destroy')
    		{
    			// if we were launched from the manager do NOT destroy session !!!
    	        if (isset($_SESSION['mgrValidated']))
    			{
    	            unset($_SESSION['webShortname']);
    	            unset($_SESSION['webFullname']);
    	            unset($_SESSION['webEmail']);
    	            unset($_SESSION['webValidated']);
    	            unset($_SESSION['webInternalKey']);
    	            unset($_SESSION['webValid']);
    	            unset($_SESSION['webUser']);
    	            unset($_SESSION['webFailedlogins']);
    	            unset($_SESSION['webLastlogin']);
    	            unset($_SESSION['webnrlogins']);
    	            unset($_SESSION['webUsrConfigSet']);
    	            unset($_SESSION['webUserGroupNames']);
    	            unset($_SESSION['webDocgroups']);   
    	        }
    	        else
    			{
    				setcookie(session_name(), '', 0, $modx->config['base_url']);
    	        }
    			
    			setcookie($cookieName, '', time()-60, '/', $_SERVER['SERVER_NAME'], 0);
    		}
    	}


    I "optimised" code ($cookieName = ’WebLoginPE’; and setcookie(....) ) to reduce the number of lines. It is easier for me to search bug wink and I replaced
    if (isset($_COOKIE[session_name()])) {setcookie(session_name(), '', 0, $modx->config['base_url']);}
    by only
    setcookie(session_name(), '', 0, $modx->config['base_url']);


    @ricksterv4n1x8: it seems to be a cookie problem. With this "fix", you have this problem again?
      Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
      • 32830
      • 21 Posts
      Kyle, thanks for sharing your iefix modification.
      It solved my firefox problem in mere seconds!!
        • 1122
        • 209 Posts
        The problem with Firefox can also be solved with a single conditional call to JavaScript patch in a "webloginpe.snippet.php":
          # apply JavaScript patch only if the request comes from IE browser
          if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
              #### original piece of code #
              $modx->regClientStartupScript('assets/snippets/webloginpe/js/ieButtonFix.js');
              # original piece of code ####
          }
        

        I suggest to correct the code in further snippet’s releases, because this simple conditional call prevents from loading and executing JavaScript code by browsers that do not require it.