View Full Version : setting cookies

08-04-2002, 07:53 AM
Hello again. [I'll stick to the rules of one post this time]

my page is littered with disclaimers, most because in all honesty, if someone came in through a different link and not the main door, then i need for them to agree to the disclaimer.

the only thing is that the disclaimer is in every new folder the person enters, so it gets a bit annoying at times. if they sign in as a user, all the disclaimers fade.

the only bad part about that is that it only lasts until the person closes their browser, and honestly, i don't even know a 'log out' code for that.

but back to the main part.

i have an accesscontrol file, as so

<?php // accesscontrol.php



if(!isset($username)) { ?>
<title> Please Log In for Access </title>
<h1> Login Required </h1>
<p>You must log in to access this area of the site. If you are
not a registered user, <a href="signup.php">click here</a>
to sign up for instant access!</p> <p><form method="post" action="<?=$PHP_SELF?>">
User ID: <input type="text" name="username" size="8"><br>
Password: <input type="password" name="password" SIZE="8"><br>
<input type="submit" value="Log in">
</form></p> </body>


$sql = "SELECT * FROM user WHERE
username = '$username' AND password = PASSWORD('$password')";$result = mysql_query($db);if (!$result) { error("A database error occurred while checking your ".
"login details.\\nIf this error persists, please ".
"contact support@me.com.");}

if (mysql_num_rows($result) == 0) { session_unregister("username"); session_unregister("password"); ?>
<title> Access Denied </title>
<h1> Access Denied </h1>
<p>Your user ID or password is incorrect, or you are not a
registered user on this site. To try logging in again, click
<a href="<?=$PHP_SELF?>">here</a>. To register for instant
access, click <a href="signup.php">here</a>.</p> </body>
<?php exit;}

$username = mysql_result($result,0,"username");

for the new folder, all INDEX files have this access control in it. also, i went ahead and added the disclaimer to the access control scrip, so now when they see 'login required', they also see a 'non-member area, disclaimer', and then it takes them to a different index.

what i want to do is rewrite this script, or something like it, that does this,

i attatch the <?php require (visotorcontrol.php) ?> something like that to the top. much as you would do with accesscontrol.

once they try to get into the folder, the big DISCLAIMER, will appear, at the bottom, they can use a check box (or a link, but a check box is fine), and check 'agree', then press enter, and then that same page shows up.

now, also, with the cookie that was just set, if they visit other folders, they won't see the disclaimer (which is pretty much as a YOU ARE NOT LOGGED IN sort of thing anyway)

does this make any sense?

visitor > enter the site > see's disclaimer > agrees to disclaimer, disclaimer (is the same page) goes away and they gain access to the page > each time visitor goes into a new folder, visitor will have instant access to the page.

sort of like a member's page with no real user or pwd.


visitor enters by way of link> tries to access a folder > sees disclaimer> agrees > cookie is set > releases the page to them > allows instant access for every other folder.

whew! this was huge.

i hope it wasn't too long, and i hope someone can help.