| Cookies | |
| documentation |
WM:
Cookies make the Web go 'Round WM: What Cookies Can Do for You WM: Advanced JS & Cookies PHP Cookies |
| Cookie |
A "cookie" is a name/value pair (example: username = zimmer) saved on a client's hard disk.
A "cookie" text file is created based on the web server and the directory from which the cookie is set. A single web server can create up to 20 cookies on a client's hard disk A cookie is retrievable by the name (ex: username) and only by the web server that created it. The client's web browser saves the cookie - client's can block this via internet settings Session cookies - cookies with no expiration date (disappear at when session ends). Persistent cookies - cookies with an expiration data in the future. Cookies can be created, retrieved, and deleted.
|
| Javascript cookies |
document.cookie can be used to access the cookie... Create a session cookie: onclick = "document.cookie =
'username = zimmer'; " Create a persistent cookie: onclick = "document.cookie =
onclick = "document.writeln(document.cookie);"
onclick = "document.cookie = ** Many functions that can assist cookie processing using JavaScript : |
| php cookies |
setcookie("name","value", ...); Create a session cookie: <? php ?> Create a persistent cookie: <? php ?>
Retrieve a cookie: - just use the cookie name portion as a variable <? php print("<br> your cookie value is $username <br>"); ?> - the above script sends the following back to the client's browser: <br>your cookie value is zimmer <br>
Delete a cookie: <? php
setcookie("username"); ?> OR <? php
setcookie("username", "", time()-60); ?>
|