I am building an intranet-like website for my high school students to use and I would like them to login using google sign-in because they all have google accounts. I have successfully integrated google sign-in using Google's instructions.
When a new user visits the first page (the login page) of my site and logs in, I would like them to be automatically redirected to the second page. I have researched this on SO and elsewhere but not found anything yet. How could I do this?
Also, if a user tries to access any page other than the first page without having first logged in, how can I redirect them to the first page?
My website address and code is below. Let me know if you need any more information. Thanks!
First page: 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>
Second page: 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>