who doesn't like cookies? I do.
And now I know how to set them via php. It's pretty easy.
Now using them will be the important part.
You can set a cookie and give it a name, like USER, or LASTVISIT, or something like that.
Then you can use it to customize the user experience, for instance by outputting the user's name back to the screen and displaying the date they last visited.
Set the cookie like this:
setcookie("user", "Andy MacKenzie", time()+7200);
Read it like this:
echo $_COOKIE["user"];
Delete it like this:
setcookie("user", "", time()-3600);
The deletion is kind of weird, you actually just set it again with a negative expiration time (in seconds). Then it will be deleted when you close the browser.
Later.
Sunday, February 27, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment