PDA

View Full Version : Help with Cookies


Smeg40k
05-13-2005, 06:17 PM
Peeps,

Right well i am trying to write a site with a simple welcome page that asks the visitor to enable java and flash for the site (If using that damn thing called IE). writes a cookie and then will automatically redirect next time the page is visited from that machine.

I thought that to do this i could use a php statment at the top of the page to check for a cookie and redirect if it exists, then on the enter link or somthing similar get it to make the cookie. Then when the user visits that page again via a bookmark or somthin it will redirect them automatically.

I believe this was because i wanted the cookie to be written when the link was clicked, and that cant be achieved.
If anybody knows of a piece of code or where i might be going wrong then cheers for the help.

You can see the code below (I admit i am more of a php scrpt kiddie).
<?php
if(isset($HTTP_COOKIE_VARS['TheBikeClinic.oc.uk'])){
echo header("Location: index2.php");
}
?>
<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Hello</title>
</head>

<body>
<p><a href="index2.php" >enter</a></p> {This is where it needs to do somthing}

</body>

</html>


Cheers

SnakEyez
05-17-2005, 01:49 PM
To fix your problem don't echo the header command. Just do header("location:...");

Smeg40k
05-23-2005, 05:15 PM
Cheers for that SnakEyez that worked for me.