How to create a cookie, using the function setcookie, how to create arguments are setcookie(name, value, expiration):

When you create a cookie, using the function setcookie, you must specify three arguments. These arguments are setcookie(name, value, expiration):
1.name: The name of your cookie. You will use this name to later retrieve your cookie, so don’t forget it!
2. value: The value that is stored in your cookie. Common values are username(string) and last visit(date).
3 expiration:- The date when the cookie will expire and be deleted. If you do not set this expiration date, then it will be treated as a session cookie and be removed when the browser is restarted.

In this example we will be creating a cookie that stores the user’s last visit to measure how often people return to Visit our webpage. We want to ignore people that take longer than two months to return to the site, so we will set the cookie’s expiration date to two months in the future!

PHP Code:
how to create cookies code

Don’t worry if you can’t follow the somewhat involved date calculations in this example. The important part is that you know how to set a cookie, by specifying the three important arguments: name, value and expiration date.