View Single Post

  #2 (permalink)  
Old 12-15-2003
Poul Møller Hansen
 
Posts: n/a
Default Re: Simple cookie usage

> I'd like to add cookies to my website but I don't understand the usage of
> it. I've read and tried the examples of the tutorial but it just don't

work
> with me.
>
> Does anyone have a little working write and read example?
>



I'm not completely sure on what your intentions are, but maybe this can be
used:

setcookie ("Username", $Userid,time()+2592000); /* expire in 30 days */
setcookie ("Country", $Country,time()+2592000); /* expire in 30 days */

if (isset($_COOKIE['Username'])) {
$Username = $_COOKIE['Username'];

unset $Country;
if (isset($_COOKIE['Country'])) {
$Country = $_COOKIE['Country'];

Remember that the setcookie mus be used before any header is sent.


Poul


Reply With Quote