首页 > 解决方案 > 如何从其他页面从 google 帐户退出?

问题描述

我已经成功地向我的网站暗示了 Google 登录,并且只要它们都在同一页面上,Signout 就可以正常工作。我在网站上有一个导航栏,它包含在每个页面(包括登录页面)的顶部,我想在导航栏上找到退出按钮,但是当我这样做时,它不再起作用了。因为我使用的是 PHP,所以我尝试设置header('location:login.php');登录和注销按钮所在的位置,然后使用 它并没有用,我还尝试在用户使用后<script src="'.$js.'script.js"></script> // this is my js script where the signOut() function is declared <script type="text/javascript"> window.onload = signOut; </script> 触发注销按钮document.getElementById("google_signout").click;用 php punction 发送到那里,header('location:login.php');它也没有工作。什么是正确的方法?顺便说一句,我在 PHP 代码中编写 Javascript 代码,就像这样:

   <?php
       if (isset($_SESSION['User'])){ // run this if the user is logged in 

            echo '<script src="'.$js.'script.js"></script> //load my script where the google signOut() is declared  
            <script type="text/javascript">
            window.onload = signOut;
            </script>';
    }else{
      //do something else
    }
 ?>

标签: javascriptphpgoogle-signin

解决方案


推荐阅读