Unlimited Faxes, No Fees, Dedicated Phone Number
|
|
What is a Cookie?A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests for a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values. How to Create a CookieThe setcookie() function is used to create cookies. Note: The setcookie() function must appear BEFORE the <html> tag. Syntax
ExampleThe following example sets a cookie named "uname" - that expires after ten hours.
How to Retrieve a Cookie ValueWhen a cookie is set, PHP uses the cookie name as a variable. To access a cookie you just refer to the cookie name as a variable. Tip: Use the isset() function to find out if a cookie has been set. ExampleThe following example tests if the uname cookie has been set, and prints an appropriate message.
|