need some help with cookies ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

need some help with cookies ...

Post by HormonX »

Can someone help me with cookies ... i need to set a cookies with 2 variables and then check that cookie for those variables and display a message is they are present.

Can anyone help ?

Greg
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

sure.

start by reading this page [php_man]setcookie[/php_man]

read the user comments too, they are your friend.

Code: Select all

<?php

setcookie('name', 'value');


// keep in mind you cant check if the cookie was set
//  until the next time the browser requests a page
if (isset($_COOKIE['name'])) {
    echo 'cookie was set.';
}

?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

note, you should set a expiration time when setting cookies.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post by HormonX »

thank you ...

that cleared up a bit :)

Greg
Post Reply