What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » php cookie help [solved]

php cookie help [solved]
Author: Message:
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / Male / –
Joined: Jun 2004
RE: php cookie help
You cant set cookies after the page has outputed anything.
And some times the page will be called when there isnt anything posted, or no cookies, so you have to check to see if there set

So use this
code:
<?php
//cookies instellen
If($_POST){    //check to see if anything has been posted to the page
setcookie ("Naam", $_POST["naam"], time()+86400);  /* onthoud naam voor 24 uur*/
setcookie ("Ipadres", $_SERVER["REMOTE_ADDR"], time()+86400); /*onthoud ip voor 24 uur */
}
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Cookie Test</title>
</head>
<body>
<form action="cookietest.php" method="post">
<input type="text" name="naam" value="<?php IF(isset($_COOKIE["Naam"])) echo $_COOKIE["Naam"] ?>">
<input type="submit" value="Cookie Instellen" name="Submit">
</form>

<?php
if(isset($_COOKIE["Naam"]) AND isset($_COOKIE["Ipadres"])){ //Check to see if the cookies are set
//dingen naar de pagina printen
print "Als je binnen 24 uur op deze pagina terugkomt, weet het script je naam nog en je ipadres";
print "<br>" . "Naam: " . $_COOKIE["Naam"] . "<br>" . "Ip-adres: " . $_COOKIE["Ipadres"];
}
?>
</body>
</html>

hope it makes sense :)

700th post :cheesy:

This post was edited on 03-07-2005 at 11:15 PM by Plik.
03-07-2005 11:12 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
php cookie help [solved] - by Ezra on 03-07-2005 at 10:13 PM
RE: php cookie help - by L. Coyote on 03-07-2005 at 10:24 PM
RE: php cookie help - by Ezra on 03-07-2005 at 10:28 PM
RE: php cookie help - by L. Coyote on 03-07-2005 at 10:36 PM
RE: php cookie help - by Ezra on 03-07-2005 at 10:41 PM
RE: php cookie help - by Plik on 03-07-2005 at 10:45 PM
RE: php cookie help - by L. Coyote on 03-07-2005 at 10:46 PM
RE: php cookie help - by Ezra on 03-07-2005 at 10:50 PM
RE: php cookie help - by Plik on 03-07-2005 at 10:55 PM
RE: php cookie help - by L. Coyote on 03-07-2005 at 10:57 PM
RE: php cookie help - by Ezra on 03-07-2005 at 11:00 PM
RE: php cookie help - by Plik on 03-07-2005 at 11:12 PM
RE: php cookie help - by L. Coyote on 03-07-2005 at 11:16 PM
RE: php cookie help - by Ezra on 03-07-2005 at 11:23 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On