writing and reading a cookie

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
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

writing and reading a cookie

Post by mzfp2 »

just need sum code to write username to a cookie and read it.

Tried scripts already available but they fail to read any value.

Any help?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can write a cookie using setcookie() and then once you've refreshed the page, you should be able to access it (assuming you've called it username) as $_COOKIE['username'].

Mac
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

You can even use sessions. But try to work with cookies first, it's more basic. :)
Post Reply