The first page of my website is this
PHP Code:
<?php
if(isset($_COOKIE['lastVisit']))
header('location: indexthesecond.php');
else
$visit = $_COOKIE['lastVisit'];
?>
<html>
<head>
<title>Randomhelp4you</title>
<?php
file_put_contents('ips.log', $_SERVER['REMOTE_ADDR'] . "\n", FILE_APPEND);
?>
<?php
$george = 60 * 60 + time();
setcookie('Authorization','no', $george);
?>
<body style="background-color:lightblue">
</head>
<body>
<form action="setcookie.php" method="post">
Name <input name="name" type="text" maxlength="10" />
<input type="submit"/>
</form>
</body>
</html>
The second page looks like this
PHP Code:
<?php
if(isset($_COOKIE['authorization']))
header('location: index.php');
else
?>
<?php
$cheese = $_POST['name'];
$inTwoMonths = 60 * 60 * 24 * 60 + time();
setcookie('lastVisit',$cheese, $inTwoMonths);
?>
<html>
<head>
<meta http-equiv="Refresh" content="3;url=http://randomhelp4you.heliohost.org/indexthesecond.php" />
</head>
<body>
<center>
<p><font size="+2">Thankyou, you will be redirected shortly</font></p>
<p>If you are not redirected, please click <a href="http://randomhelp4you.heliohost.org/indexthesecond.php">here</a>.</p>
</center>
</body>
</html>
and the third page looks like this
PHP Code:
<?php
if(isset($_COOKIE['lastVisit']))
$visit = $_COOKIE['lastVisit'];
else
header('location: index.php');
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="basic.css" />
<title>Randomhelp4you</title>
</script>
<body style="background-color:lightblue">
</head>
<body>
<h1><center>Randomhelp4you</center></h1>
<?php
echo "Hey ". $visit;
?>
</body>
</html>
The idea behind it is that the go onto he index page (php) and enter their name. This form is procesed by setcookie.php . This page sets a cookie with their name on it, then redirects them to indexthesecond.php , were it displays their name. If they try to acess indexthesecond.php without the cookie, they should be redirected to index.php . If they try to go onto index.php with the cookie then they are redirected to indexthesecond.php . This all works fine but I am trying to add in an extra cookie with a 60 minute timeout which is assigned by index.php . This is to make sure that when they go to setcookie.php they came from index.php . I'm trying to explain this easily but if it dosen't make sense just tell me.
Bookmarks