Creating a Cookie
<?php
setcookie('version', phpversion());
?>
Tried to send cookie.
|
To create a cookie, the PHP function setcookie() can be used. It expects the following parameters; however, only the first one is mandatory:
The expiry date (in UNIX epoche format) The path on the web server from which the cookie may be accessed The domain from which the cookie may be accessed Whether the cookie may only be sent using secure (HTTP Secure [HTTPS]/Secure Sockets Layer [SSL]) connections
The preceding code sets a simple session cookie with the current PHP version as its value.
Figure 5.2 shows a cookie warning in the Firefox browser. You can clearly see the cookie name and script.

 |