我正在建立一个类似Intranet的网站供我的高中生使用,我希望他们使用谷歌登录登录,因为他们都有谷歌帐户。我已经使用Google的说明成功整合了Google登录功能。从登录页面重定向
当新用户访问我网站的第一页(登录页面)并登录时,我希望它们自动重定向到第二页。我在SO和其他地方研究过这个,但还没有发现任何东西。我怎么能这样做?
此外,如果用户尝试访问除第一页以外的任何页面而未先登录,那么如何将它们重定向到第一页?
我的网站地址和代码如下。让我知道你是否需要更多信息。谢谢!
第一页:http://davidstarshaw.atwebpages.com/test/index.php
<!DOCTYPE html>
<head>
<title>Test login page</title>
<meta name="google-signin-client_id" content="795531022003-rdb02epf7o0qpr5p83326icrseh82gqa.apps.googleusercontent.com"> <!--My google sign-in client ID-->
<script src="https://apis.google.com/js/platform.js" async defer</script> <!--Google platform library. Needed for sign-in-->
<script src="script.js" async defer></script>
</head>
<body>
<p>This is the first page.</p>
<div class="g-signin2" data-onsuccess="onSignIn"></div> <!--This code is straight from google-->
<a href="#" onclick="signOut();">Sign out</a><br>
<a href=home.php>Manually go to the second page</a>
</body>
第二页:http://davidstarshaw.atwebpages.com/test/home.php
<!DOCTYPE html>
<head>
<title>Test home page</title>
<meta name="google-signin-client_id" content="795531022003-rdb02epf7o0qpr5p83326icrseh82gqa.apps.googleusercontent.com"> <!--My google sign-in client ID-->
<script src="https://apis.google.com/js/platform.js" async defer></script> <!--Google platform library. Needed for sign-in-->
<script src="script.js" async defer></script>
</head>
<body>
<p>This is the second page.</p>
<div class="g-signin2" data-onsuccess="onSignIn"></div> <!--This code is straight from google-->
<a href="#" onclick="signOut();">Sign out</a><br>
<a href=index.php>Manually go back to the first page</a>
如何保存成功登录?使用会话?如果没有,请设置一个名为“loggedIn”的会话,如果没有设置,就重定向到登录页面,如果设置了第一页,则重定向到第二页面。 –
使用标题功能重定向 –