Actually, sessions are by far the easiest way๐
The following can be adapted to your page that verifies login.
If login is correct.....
session_start();
header("Cache-control: private");
$TempPassCode = session_id();
$_SESSION['KeyCode'] = $TempPassCode;
header("Location: MembersPage.php?SessionID=$TempPassCode");
exit;
This will produce the URL ending such as this (with the actual variable
value length being determined by your host, but is irrelavent
since is somewhat self created by the "session_id()"):
MembersPage.php?SessionID=3be4ae6b8c1e05f760f6c2b44538c8e9
Now, within the MembersPage.php, you would include the following:
<?php
session_start();
header("Cache-control: private");
$Verify1 = $_SESSION['KeyCode'];
$Verify2 = $HTTP_GET_VARS['SessionID'];
if($Verify2 == "") {
header("Location: login.php");
exit;
} else {
if($Verify1 == $Verify2) {
echo 'Your HTML for the member's page goes here...';
} else {
header("Location: login.php");
exit;
}
}
?>
What this does is check to make sure the current LIVE session-key
we named "KeyKode" on the previous page matches that of the
passed one in the URL. If so, echo HTML of page. If not, redirect
back to login page! You'll notice that the header
("Location: login.php"); is there twice. This is to cover a
failure of some PHP configurations. 1st one sents back to login if
the variable is blank, the other if present but no match. Oddly
enough, without both of them some configs will show as valid on
a blank or non-passed variable (the "?SessionID="). By using
this, if they close browser (even if bookmark for next time) or
copy+paste to another window, they will be sent right back to
the beginning๐
Notice that both pages start with
session_start();
header("Cache-control: private");
This is neccessary, even though you would think you've
already "started" the session. Sessions are not kept-alive from
page to page (not kept open like MySQL) literally...So you have to
tell each page to keep going with the session.
To add this protection of them being required to be in the same
session on all members pages, you can include this check-system
in all the pages...JUST MAKE SURE to remember and pass
the "SessionID" variable.
To log them out, and kill the session - In the logout page:
<?
session_start();
$_SESSION = array();
session_destroy();
?>
This isn't perfect, but I think it should solve the problem without you going nuts over it๐
A basic tutorial over session can be found at PHP Freaks. And go check-out PHP.net and look-up "sessions"๐