


“” is optional, it can be used to define the cookie access hierarchy i.e.Sub directories limit the cookie access to the subdomain. The forward slash “/” means that the cookie will be made available on the entire domain. “” is optional it can be used to set the cookie path on the server.The time is set using the PHP time() functions plus or minus a number of seconds greater “” is optional it can be used to set the expiry time for the cookie such as 1 hour.“cookie_value” is the value of the cookie and its mandatory.“cookie_name” is the name of the cookie that the server will use when retrieving its value from the $_COOKIE array variable.Php“setcookie” is the PHP function used to create the cookie.Let’s now look at the basic syntax used to create a cookie.

Personalizing the user experience – this is achieved by allowing users to select their preferences.The page requested that follow are personalized based on the set preferences in the cookies.Http is a stateless protocol cookies allow us to track the state of the application using small files stored on the user’s computer.The path were the cookies are stored depends on the browser.Internet Explorer usually stores.Requests from the user will return the cookie name and value The diagram shown below illustrates how cookies work.ġ) A user requests for a page that stores cookiesĢ) The server sets the cookie on the user’s computer If this is the case then PHP responds by passing the cookie token in the URL. Most web browsers have options for disabling cookies, third party cookies or both. These are known as third party cookies.Ī cookie created by a user can only be visible to them. The domains serving these elements can also set their own cookies. Most of the websites on the internet display elements from other domains such as advertising. For example, a cookie set using the domain can not be read from the Once a cookie has been set, all page requests that follow return the cookie name and value.Ī cookie can only be read from the domain that it has been issued from.
