Wechat jumps to the previous page after the successful authorization of the web page.

if you want to jump to the page before authorization after successful authorization, use header ("Location:". $_ SERVER ["HTTP_REFERER"]) in the successful authorization controller;
find that you can"t get $_ SERVER [" HTTP_REFERER"]

The structure of the

code is as follows: there is a construction method to determine whether you have logged in or not to jump to the authorization page of the web page:

public function wxOauth()
      {
           var_dump($_SERVER["HTTP_REFERER"]);die();
          
          if(isset($_GET["code"])){
                $token=$this->weObj->getOauthAccessToken();
                
                $userinfo=$this->weObj->getOauthUserinfo($token["access_token"],$token["openid"]);
                // openid id id   id
            
                // $_SERVER["HTTP_REFERER"]
                
                
                echo $this->rurl;
                //header("location:".$this->rurl);
              
          }else{
              //$_SERVER["REQUEST_URI"]
              
             
              $this->rurl=$_SERVER["HTTP_REFERER"];
              
            $host="http://".$_SERVER["HTTP_HOST"].__SELF__;
            $url=$this->weObj->getOauthRedirect($host);
            
            
            header("location:".$url);
              
          }
        //  
            
            
            

        }

  1. redirect_url
  2. Save the page before authorization in cookie or session

do you want to get the last web page the user visited?

when authorization is successful, it is called back by Wechat himself, so there is no referer , which requires you to concatenate the previous page as one of the callback parameters when authorizing.

such as redirect_url=xxx.youDomain.com/WechatOauthSuccess/yourPrevPage


what happened in the end?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c24e4f-3373b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c24e4f-3373b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?