I am trying to create a password protected website. Here I want to do if a user first time visit to my website then need to insert password to access my website. First time they entered the password they can freely access my website.
This is how I do it using javascript
and php
:
<?php if($page == 'index'): ?>
<script language="Javascript">
//prompt.
var password;
var correctPass = "123456";
password = prompt("Enter in the password:","");
if(password == correctPass) {
alert('click OK to view this site');
} else {
window.location = "http://google.com"
}
//->
</script>
<?php endif; ?>
This is working but my problem is if user go to the index page again they need to insert the password.
can anybody tell me how I fix this issue. Thank you.