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

Pages: (2): « First « 1 [ 2 ] Last »
php cookie help [solved]
Author: Message:
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
O.P. RE: php cookie help
@ Madman thnx for clearing that up. And i changed it to
code:
setcookie ("Naam", $_POST["naam"], time()+86400);  /* onthoud naam voor 24 uur*/
setcookie ("Ipadres", $_SERVER["REMOTE_ADDR"], time()+86400); /*onthoud ip voor 24 uur */


And... still nothing :'(
[Image: 1-0.png]
             
03-07-2005 11:00 PM
Profile PM Web Find Quote Report
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
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
RE: php cookie help
I knew I'd find out after someone else pointed it out. 8-)

I suddenly feel old... :s

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

03-07-2005 11:16 PM
Profile PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
O.P. RE: php cookie help
It works :d

I should read www.php.net better next time i try something :P
[Image: 1-0.png]
             
03-07-2005 11:23 PM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


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