Created
April 16, 2022 19:07
-
-
Save tobiasroeder/e4ef7d06d5dd5167f2de5b1bb0afeaaa to your computer and use it in GitHub Desktop.
Locking/unlocking a website, e.g. for a landing page that is currently in a beta phase.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Coming Soon</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// start the session to be able to read the unlock key | |
session_start(); | |
// get the unlock key - as fallback the variable contains an empty string | |
$session_unlock_key = $_SESSION['unlock_key'] ?? ''; | |
// check if the session unlock key is correct | |
// if not show the landing page | |
if ($session_unlock_key !== '__YOUR_SESSION_UNLOCK_KEY__') { | |
require __DIR__ . '/coming-soon.html'; | |
exit; | |
} | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// start the session to be able to remove the unlock key | |
session_start(); | |
// clear all session variables | |
session_unset(); | |
// remove all session data | |
session_destroy(); | |
// redirect to the home directory, this will be in our case the index.php file | |
header('Location: /'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// start the session to be able to set the unlock key | |
session_start(); | |
// set the unlock key | |
$_SESSION['unlock_key'] = '__YOUR_SESSION_UNLOCK_KEY__'; | |
// redirect to the home directory, this will be in our case the index.php file | |
header('Location: /'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment