Meaning, if someone were to search for “Name of site: page name” wouldn’t it show up?
I decided to try using cookies.
This is at the very top:
[php]if (isset($_POST[‘password’]) && $_POST[‘password’]==“dlady777”) {
setcookie(“loggedin”, “yes”, time()+3600);
}[/php]
Then the condition statement further down:
[php]if (isset($_COOKIE[‘loggedin’]) && $_COOKIE[‘loggedin’]==“yes”) {
Display content.
} else {
Display error message.
}[/php]
What happens now is the password isn’t accepted but the cookie is still set, so when I enter any random password after that it lets me through. On the positive side, this seems to solve the problem with PayPal.
What did I do wrong?
I see you marked this resolved. Did you figure it out? Without seeing your full code it’s hard to know where the problem is. Cookies and sessions should work the same.
Yup, I finally got it working. Here’s what I came up with.
At the top:
[php]session_start();
$id = session_id();
$password = “dlady777”;
if (isset($_POST[‘password’])) {
if ($_POST[‘password’] == $password) {
header('Location: ’ . $_SERVER[‘PHP_SELF’] . ‘?id=’ . $id . ‘’);
} else {
$verified = FALSE;
}
} else {
$verified = FALSE;
}
if (isset($_GET[‘id’])) {
if ($_GET[‘id’] == $id) {
$verified = TRUE;
} else {
$verified = FALSE;
}
}[/php]
And the condition statement:
[php]if ($verified == TRUE) {
Display content.
} else {
Display error message.
}[/php]
Thanks for your tips.
That is essentially the same as my first solution. Instead of using an encoded password string you are using the session_id.
As long as it works for you, great
Well, with your suggestion the string was static, which meant anyone could access the page without having to put in a password, whereas now it only works for each individual in one specific browser session. I did work off of your suggestion though, so thanks.
True, but if you noticed how I added the “token”, that token could be the session_id. Something to think about