PHP Tutorial

A web server programming language.

PHP Cookies

PHP Cookies

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 a page with a browser, it will send the cookie too.

Create a Cookie with PHP

Use the setcookie() function.

setcookie(name, value, expire, path, domain, secure, httponly);

Important: The setcookie() function must appear BEFORE the <html> tag.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics