{"id":85,"date":"2021-03-08T00:15:52","date_gmt":"2021-03-08T00:15:52","guid":{"rendered":"https:\/\/phptutorial.net\/?page_id=85"},"modified":"2025-04-06T07:58:57","modified_gmt":"2025-04-06T07:58:57","slug":"php-cookies","status":"publish","type":"page","link":"https:\/\/www.phptutorial.net\/php-tutorial\/php-cookies\/","title":{"rendered":"PHP Cookies"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn about cookies and how to use the PHP <code>setcookie()<\/code> function to manage cookies effectively.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-cookies'>Introduction to cookies <a href=\"#introduction-to-cookies\" class=\"anchor\" id=\"introduction-to-cookies\" title=\"Anchor for Introduction to cookies\">#<\/a><\/h2>\n\n\n\n<p>The web works based on the HTTP protocol. The HTTP protocol is stateless.<\/p>\n\n\n\n<p>When a web browser requests a page from a web server, the web server responds with the page content. Later, the same web browser requests the same page again, and the web server has no information that the request is from the same web browser.<\/p>\n\n\n\n<p>Cookies solve this stateless challenge.<\/p>\n\n\n\n<p>A cookie is a piece of data a web server sends to the web browser. The browser may store it and send it back in subsequent requests to the same web server. By using the same cookie, the web server knows that two requests come from the same web browser.<\/p>\n\n\n\n<p>Cookies are also known as web cookies, HTTP cookies, or browser cookies. We&#8217;ll use the cookies to make it short.<\/p>\n\n\n\n<p>The following flow chart illustrates how cookies work:<\/p>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"530\" height=\"254\" class=\"wp-image-2197\" src=\"https:\/\/phptutorial.net\/wp-content\/uploads\/2021\/07\/php-cookies.png\" alt=\"PHP cookie\" srcset=\"https:\/\/www.phptutorial.net\/wp-content\/uploads\/2021\/07\/php-cookies.png 530w, https:\/\/www.phptutorial.net\/wp-content\/uploads\/2021\/07\/php-cookies-300x144.png 300w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><\/figure>\n<\/div>\n\n\n\n<p>How it works.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, the web browser sends a request to the web server. The web server doesn&#8217;t have any information about the web browser. The web server creates a cookie with a name return and a value 1 and attaches the cookie to the HTTP response header. To create a cookie, you&#8217;ll use the <code>setcookie()<\/code> function.<\/li>\n<li>Second, the web browser stores the cookie.<\/li>\n<li>Third, the web browser sends the second request with the stored cookie in the header of the HTTP request to the web server. On the web server, PHP can access the cookie via the <code>$_COOKIE<\/code> superglobal variable and do something accordingly.<\/li>\n<li>Finally, the web server responds with the content of the request. Typically, it responds to the web browser with the content based on the value of the cookie.<\/li>\n<\/ul>\n\n\n\n<p>A web browser can store a cookie with a maximum size of 4KB, but this limit varies between browsers.<\/p>\n\n\n\n<p>A cookie has an expiration date. Typically, web browsers store cookies for a specific duration, and the web server can specify the expiration time for a cookie.<\/p>\n\n\n\n<p>A cookie also stores the web address (URL) that indicates the URL that created the cookie. The web browser can send back the cookie that was originally set by the same URL. In other words, a website won&#8217;t be able to read a cookie set by other websites.<\/p>\n\n\n\n<p>Most modern web browsers allow users to choose to accept cookies. Therefore, you should not wholly rely on cookies for storing critical data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='why-using-cookies'>Why using cookies <a href=\"#why-using-cookies\" class=\"anchor\" id=\"why-using-cookies\" title=\"Anchor for Why using cookies\">#<\/a><\/h2>\n\n\n\n<p>In general, websites use cookies to enhance user experiences. For example, you would have to log in to a website again after you leave it without cookies.<\/p>\n\n\n\n<p>Typically, you&#8217;ll use cookies for the following purposes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/phptutorial.net\/php-tutorial\/php-session\/\">Session management<\/a>: cookies allow a website to remember users and their login information or anything else the web server should remember.<\/li>\n<li>Personalization: cookies can store user&#8217;s preferences, themes, and other settings.<\/li>\n<li>Tracking: cookies store user behavior. For example, on an E-commerce website, you can use cookies to record the products that users previously viewed. Later, you can use this information to recommend the related products that users might be interested in.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='setting-a-cookie-in-php'>Setting a cookie in PHP <a href=\"#setting-a-cookie-in-php\" class=\"anchor\" id=\"setting-a-cookie-in-php\" title=\"Anchor for Setting a cookie in PHP\">#<\/a><\/h2>\n\n\n\n<p>PHP\u00a0makes it easy to work with cookies using the <code>setcookie()<\/code> function. The <code>setcookie()<\/code> function allows you to send an HTTP header to create a cookie on the web browser.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\nsetcookie ( \n    string $name , \n    string $value = <span class=\"hljs-string\">\"\"<\/span> , \n    int $expires = <span class=\"hljs-number\">0<\/span> , \n    string $path = <span class=\"hljs-string\">\"\"<\/span> , \n    string $domain = <span class=\"hljs-string\">\"\"<\/span> , \n    bool $secure = <span class=\"hljs-keyword\">false<\/span> , \n    bool $httponly = <span class=\"hljs-keyword\">false<\/span> \n): bool<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following table illustrates the arguments of the <code>setcookie()<\/code> function:<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>Argument<\/th>\n<th>Meaning<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>$name<\/td>\n<td>The name of the cookie<\/td>\n<\/tr>\n<tr>\n<td>$value<\/td>\n<td>The value of the cookie. It can be any scalar value, such as a string or integer.<\/td>\n<\/tr>\n<tr>\n<td>$expires<\/td>\n<td>The time (in a UNIX timestamp) the cookie expires. If <code>$expires<\/code> is not set or set to 0, the cookie will expire when the web browser closes.<\/td>\n<\/tr>\n<tr>\n<td>$path<\/td>\n<td>The path on the web server on which the cookie will be available. For example, if the path is &#8216;\/&#8217;, the cookie will be available within the domain.<\/td>\n<\/tr>\n<tr>\n<td>$domain<\/td>\n<td>The domain to which the cookie will be available.<\/td>\n<\/tr>\n<tr>\n<td>$secure<\/td>\n<td>if $secure is set to <code>true<\/code> , the cookie should be transmitted over a secured HTTP (HTTPS) connection from the web browser.<\/td>\n<\/tr>\n<tr>\n<td>$httponly<\/td>\n<td>if <code>$httponly<\/code> is true, the cookie can be accessed only via the HTTP protocol, not JavaScript.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n\n<p>As of PHP 7.3.0, you can use the same <code>setcookie()<\/code> function with an alternative signature:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">setcookie ( \n    string $name , \n    string $value = <span class=\"hljs-string\">\"\"<\/span> , \n    <span class=\"hljs-keyword\">array<\/span> $options = &#91;] ) : bool<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>$options<\/code> argument is an array that has one or more keys, such as <code>expires<\/code>, <code>path<\/code>, <code>domain<\/code>, <code>secure<\/code>, <code>httponly<\/code> and <code>samesite<\/code>. The <code>samesite<\/code> can take a value of <code>None<\/code>, <code>Lax<\/code>, or <code>Strict<\/code>. If you use any other key, the <code>setcookie()<\/code> function will raise a warning.<\/p>\n\n\n\n<p>The <code>setcookie()<\/code> function returns <code>true<\/code> if it successfully executes. Notice that it doesn&#8217;t indicate whether the web browser accepts the cookie. The <code>setcookie()<\/code> function returns <code>false<\/code> if it fails.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='_cookie'>$_COOKIE <a href=\"#_cookie\" class=\"anchor\" id=\"_cookie\" title=\"Anchor for $_COOKIE\">#<\/a><\/h2>\n\n\n\n<p>The <code>$_COOKIE<\/code> an <a href=\"https:\/\/phptutorial.net\/php-tutorial\/php-associative-arrays\/\">associative array<\/a> that stores the HTTP cookies. To access a cookie by a name, you use the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$_COOKIE&#91;<span class=\"hljs-string\">'cookie_name'<\/span>]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If the cookie name contains dots (<code>.<\/code>) and spaces (<code>' '<\/code>), you need to replace them with underscores (<code>_<\/code>).<\/p>\n\n\n\n<p>To check if a cookie is set, you use the <code>isset()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">if<\/span>(<span class=\"hljs-keyword\">isset<\/span>($_COOKIE&#91;<span class=\"hljs-string\">'cookie_name'<\/span>])) {\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>$_COOKIE<\/code> is a superglobal variable so that it can be accessed from anywhere in the script.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='reading-a-cookie'>Reading a cookie <a href=\"#reading-a-cookie\" class=\"anchor\" id=\"reading-a-cookie\" title=\"Anchor for Reading a cookie\">#<\/a><\/h2>\n\n\n\n<p>Before reading a cookie value, you should always check if it has been set by using the <code>isset()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">if<\/span> (<span class=\"hljs-keyword\">isset<\/span>($_COOKIE&#91;<span class=\"hljs-string\">'cookie_name'<\/span>])) {\n\t<span class=\"hljs-comment\">\/\/ process the cookie value<\/span>\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To check if a cookie equals a value, you use the following code:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">if<\/span> (<span class=\"hljs-keyword\">isset<\/span>($_COOKIE&#91;<span class=\"hljs-string\">'cookie_name'<\/span>]) &amp;&amp; $_COOKIE&#91;<span class=\"hljs-string\">'cookie_name'<\/span>] == <span class=\"hljs-string\">'value'<\/span>) {\n\t<span class=\"hljs-comment\">\/\/ ...<\/span>\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='deleting-a-cookie'>Deleting a cookie <a href=\"#deleting-a-cookie\" class=\"anchor\" id=\"deleting-a-cookie\" title=\"Anchor for Deleting a cookie\">#<\/a><\/h2>\n\n\n\n<p>If you don&#8217;t use a cookie, you can force the browser to delete it. PHP doesn&#8217;t provide a function that directly deletes a cookie. However, you can delete a cookie using the <code>setcookie()<\/code> function by setting the expiration date to the past.<\/p>\n\n\n\n<p>The following code deletes a cookie with the <code>cookie_name<\/code> in the subsequent page request:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">unset<\/span>($_COOKIE&#91;<span class=\"hljs-string\">'cookie_name'<\/span>]);\nsetcookie(<span class=\"hljs-string\">'cookie_name'<\/span>, <span class=\"hljs-keyword\">null<\/span>, time()<span class=\"hljs-number\">-3600<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='php-cookie-example'>PHP cookie example <a href=\"#php-cookie-example\" class=\"anchor\" id=\"php-cookie-example\" title=\"Anchor for PHP cookie example\">#<\/a><\/h2>\n\n\n\n<p>The following example shows how to use a cookie to display a greeting message to a new or returning visitor.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\ndefine(<span class=\"hljs-string\">'ONE_WEEK'<\/span>, <span class=\"hljs-number\">7<\/span> * <span class=\"hljs-number\">86400<\/span>);\n\n$returning_visitor = <span class=\"hljs-keyword\">false<\/span>;\n\n<span class=\"hljs-keyword\">if<\/span> (!<span class=\"hljs-keyword\">isset<\/span>($_COOKIE&#91;<span class=\"hljs-string\">'return'<\/span>])) {\n\tsetcookie(<span class=\"hljs-string\">'return'<\/span>, <span class=\"hljs-string\">'1'<\/span>, time() + ONE_WEEK);\n} <span class=\"hljs-keyword\">else<\/span> {\n\t$returning_visitor = <span class=\"hljs-keyword\">true<\/span>;\n}\n\n<span class=\"hljs-keyword\">echo<\/span> $returning_visitor ? <span class=\"hljs-string\">'Welcome back!'<\/span> : <span class=\"hljs-string\">'Welcome to my website!'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, define a constant that stores one week in seconds:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">define(<span class=\"hljs-string\">'ONE_WEEK'<\/span>, <span class=\"hljs-number\">7<\/span> * <span class=\"hljs-number\">86400<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, set the returning_visitor to false:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$returning_visitor = <span class=\"hljs-keyword\">false<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, check the cookie with the name return. If the cookie is not set, create one with the value one and an expiration date of one week. Otherwise, set the $returning_visitor variable to true.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">if<\/span> (!<span class=\"hljs-keyword\">isset<\/span>($_COOKIE&#91;<span class=\"hljs-string\">'return'<\/span>])) {\n\tsetcookie(<span class=\"hljs-string\">'return'<\/span>, <span class=\"hljs-string\">'1'<\/span>, time() + ONE_WEEK);\n} <span class=\"hljs-keyword\">else<\/span> {\n\t$returning_visitor = <span class=\"hljs-keyword\">true<\/span>;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, display the greeting message based on the value of the <code>$returning_visitor<\/code> variable.<\/p>\n\n\n\n<p>When you request the page for the first time, you&#8217;ll see the following message:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Welcome to my website!<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you open the web developer tool, you&#8217;ll see the cookie as shown in the following picture:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"701\" height=\"192\" class=\"wp-image-2205\" src=\"https:\/\/phptutorial.net\/wp-content\/uploads\/2021\/07\/php-cookie-devtools.png\" alt=\"\" srcset=\"https:\/\/www.phptutorial.net\/wp-content\/uploads\/2021\/07\/php-cookie-devtools.png 701w, https:\/\/www.phptutorial.net\/wp-content\/uploads\/2021\/07\/php-cookie-devtools-300x82.png 300w\" sizes=\"auto, (max-width: 701px) 100vw, 701px\" \/><\/figure>\n\n\n\n<p>Since the web browser already stores the cookie with the name <code>return<\/code> and value <code>1<\/code>, if you refresh the page, you&#8217;ll see a different message:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Welcome back!<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This cookie will last for seven days set by the webserver. Of course, you can manually delete the cookie from the web browser.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A cookie is a piece of data the web server sends to a web browser to check if two requests come from the same web browser.<\/li>\n<li>Use the PHP <code>setcookie()<\/code> function to set a cookie sent along with an HTTP header from the web server to the web browser.<\/li>\n<li>Use the superglobal variable <code>$_COOKIE<\/code> to access the cookies in PHP.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Did you find this tutorial useful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"85\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-tutorial\/php-cookies\/\"\n\t\t\t\tdata-post-title=\"PHP Cookies\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"85\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-tutorial\/php-cookies\/\"\n\t\t\t\tdata-post-title=\"PHP Cookies\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn about cookies and how to use the setcookie() function to manage cookies effectively.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":15,"menu_order":79,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-85","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":5,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/85\/revisions"}],"predecessor-version":[{"id":3145,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/85\/revisions\/3145"}],"up":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/15"}],"wp:attachment":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/media?parent=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}