{"id":13668,"date":"2016-07-07T16:15:10","date_gmt":"2016-07-07T13:15:10","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=13668"},"modified":"2018-01-09T10:49:45","modified_gmt":"2018-01-09T08:49:45","slug":"php-cookie-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/","title":{"rendered":"Php Cookie Example"},"content":{"rendered":"<p>Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client after a connection), web developers need a way to store user preferences or allow their scripts to remember details about each client. \u00a0Cookies take on to solve this problem. (There are other solutions like sessions which is a great one or query strings which are less preferable).<\/p>\n<p>For this example we will use<\/p>\n<ol>\n<li>A computer with PHP 5.5 installed.<\/li>\n<li>notepad++.<\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n[ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;]<\/p>\n<h2>1.\u00a0Getting Started<\/h2>\n<p>To demystify cookies in php, we will develop a simple web app that allows users to select the font style and font size to display on a website and store this preference.<\/p>\n<h3>1.1 Working With Cookies<\/h3>\n<p>Cookies identify a user. They\u00a0allow web developers to store a small amount of data on the user browser(not more than 4kb). Each time a request is sent to the server, the cookies stored on the browser are automatically sent with the request and can be accessed by the server.<br \/>\nCookies are reliable but they are not that secure because attackers can easily tamper with them. Thus you should never use cookies alone to authenticate your users or store sensitive data in cookies (e.g passwords). Users have the possibility to\u00a0turn off cookies support in there browsers, so you should be careful when the core functionality of your web app depends on cookies. (If your web app depends on cookies to work properly, you should always check if cookies are supported in the browser and if it is not, alert the user about the error.)<\/p>\n<h3>1.2 Creating cookies in php<\/h3>\n<p>To create a cookie in php we use the <code>setcookie(name,value,expires,path,domain,secure,httponly)<\/code> function, which takes 7 parameters.<\/p>\n<h3>1.3 Cookie field and their description<\/h3>\n<ul>\n<li>Name: This is the name of the cookie.<\/li>\n<li>Value: This is the value of the cookie.<\/li>\n<li>Expires: This is the time the cookie will expire. If this value is set to a past time or if the time is already reached, the cookie is deleted from the browser. If the value is set to zero or is omitted the cookie lasts as long as the browser is running and then it\u00a0automatically deleted when the browser exits.<\/li>\n<li>Path: The path that the browser should send the cookie back to. If specified, the browser will only send the cookie to urls that contain this path. If a value is not specified for this field, the current directory is assumed.<\/li>\n<li>Domain: The (sub)domain that the cookie is available to.<\/li>\n<li>Secure: It is a boolean value, which indicates whether the cookie should be transmited over a secure (https) connection.<\/li>\n<li>Httponly: When TRUE the cookie will be made accessible only through the HTTP protocol. This means that the cookie won&#8217;t be accessible by scripting languages, such as JavaScript.<\/li>\n<\/ul>\n<h3>1.4 Code<\/h3>\n<p><span style=\"text-decoration: underline;\"><em>index.php<\/em><\/span><\/p>\n<pre class=\"brush:html; highlight:[2,4, 7,29,30]\">&lt;?php\r\nif (isset($_POST[\"size\"])){\r\n$size=$_POST[\"size\"];\/\/check if the size variable is set\r\nsetcookie(\"size\", $size,0,\"\/\",\"\",false,true);\r\n\r\n}\r\nif (isset($_POST[\"font\"])){\r\n$font=$_POST[\"font\"];\/\/check if the size variable is set\r\nsetcookie(\"font\", $font,0,\"\/\",\"\",false,true);\r\n}\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=eng&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;\r\nDynamic php and html table testing\r\n&lt;\/title&gt;\r\n&lt;style&gt;\r\nhtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\np{\r\nfont-size:&lt;?php if(isset($_COOKIE[\"size\"])) echo $_COOKIE[\"size\"]; else echo \"1em\"   ?&gt;;\r\nfont-style:&lt;?php  if(isset($_COOKIE[\"font\"])) echo $_COOKIE[\"font\"]; else echo \"italic\"     ?&gt;;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body bgcolor=\"#e5a010\"&gt;\r\n&lt;p&gt;\r\n What Is  PHP?  PHP is a programming language for building dynamic, interactive Web sites. As a general rule, PHP programs run \r\n on a Web server, and serve Web pages to visitors on request. One of the key features of PHP is that you can embed PHP code \r\n within HTML Web pages, making it very easy for you to create dynamic content quickly. \r\n &lt;\/p&gt;\r\n &lt;p&gt;\r\n What exactly does the phrase  \"dynamic, interactive Web sites\"  mean? A  dynamic  Web page is a page whose contents can \r\n change automatically each time the page is viewed. Contrast this with a  static  Web page, such as a simple HTML file, which \r\n looks the same each time it's displayed (at least until the page is next edited). Meanwhile, an  interactive  Web site is a\r\n site that responds to input from its visitors. A Web forum is a good example, users can post new messages to the forum, \r\n which are then displayed on the site for all to see\r\n &lt;\/p&gt;\r\n&lt;div&gt;\r\n&lt;form method=post action=index.php&gt;\r\n&lt;label&gt;Choose Font Style&lt;\/label&gt;\r\n&lt;select name=font&gt;\r\n&lt;option value=\"normal\"&gt;\r\nNormal\r\n&lt;\/option&gt;\r\n&lt;option  value=\"italic\"&gt;\r\nItalic\r\n&lt;\/option&gt;\r\n&lt;\/select&gt;\r\n&lt;label&gt;Choose Font Size&lt;\/label&gt;\r\n&lt;select name=size&gt;\r\n&lt;option value=\"1em\"&gt;\r\n1\r\n&lt;\/option&gt;\r\n&lt;option  value=\"2em\"&gt;\r\n2\r\n&lt;\/option&gt;\r\n&lt;\/select&gt;\r\n&lt;input type=submit value=\"Submit Form\"&gt;\r\n&lt;\/form&gt;\r\n&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n\r\n<\/pre>\n<p>In line 2 and line 7 we use the <code>isset()<\/code> function to check if the user has chosen a font size and font style.(It is\u00a0a\u00a0good practice to check if a form value is present before using it). If the user has chosen a font style and font size we call the <code>setcookie()<\/code> method to create the cookie on the browser. In line 4 we created a cookie named size which stores the font size while in line 7 we created a cookie named font which stores the font style.<\/p>\n<p>In lines 29 and 30 we checked to see if a cookie has been created. If the cookie is available we use its value to set the font style and size in css. If a cookie has not been transmitted to the browser we set the font style and size to a default value. Cookies can be accessed with <code> $_COOKIE <\/code> global variable.<br \/>\nWhen the browser is closed the size and font cookies are deleted, since we set the time value to zero. To allow the cookie to last longer than the current browser season, we supply a time value in the future. <code> setcookie(\"font\", $font,time()+60*60*24,\"\/\",\"\",false,true);<\/code> the <code> time()<\/code>function returns the current time in UNIX timestamp format. So the expiry time is 60 * 60*24 plus the current time(so the cookie would expire one day from the current time). You might need to refresh your browser to see the result of your selections.<\/p>\n<h3>1.5 Deleting Cookies In Php<\/h3>\n<p><span style=\"text-decoration: underline;\"><em>delete.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[2,6]\"> \r\n&lt;?php\r\nif (isset($_COOKIE[\"size\"])){\r\nsetcookie(\"size\", $size,time()-60 *60*24,\"\/\",\"\",false,true);\/\/cookie named size is deleted by set time option to a time in the past\r\n\r\n}\r\nif (isset($_COOKIE[\"font\"])){\r\n\r\nsetcookie(\"font\", $font,time()-60 *60*24,\"\/\",\"\",false,true);\/\/cookie named font is deleted by set time option to a time in the past\r\n}\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=eng&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;\r\nDynamic php and html table testing\r\n&lt;\/title&gt;\r\n&lt;style&gt;\r\nhtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\np{\r\nfont-size:&lt;?php if(isset($_COOKIE[\"size\"])) echo $_COOKIE[\"size\"]; else echo \"1em\"   ?&gt;;\r\nfont-style:&lt;?php  if(isset($_COOKIE[\"font\"])) echo $_COOKIE[\"font\"]; else echo \"italic\"     ?&gt;;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body bgcolor=\"#e5a010\"&gt;\r\n&lt;?php\r\nif(!isset($_COOKIE[\"size\"]))\r\necho \"&lt;p&gt;cookie named size has been deleted&lt;\/p&gt;\";\r\nif(!isset($_COOKIE[\"font\"]))\r\necho \"&lt;p&gt;cookie named font has been deleted&lt;\/p&gt;\";\r\n?&gt;\r\n&lt;p&gt;\r\n What Is  PHP?  PHP is a programming language for building dynamic, interactive Web sites. As a general rule, PHP programs run \r\n on a Web server, and serve Web pages to visitors on  One of the key features of PHP is that you can embed PHP code \r\n within HTML Web pages, making it very easy for you to create dynamic content quickly. \r\n &lt;\/p&gt;\r\n &lt;p&gt;\r\n What exactly does the phrase  \"dynamic, interactive Web sites\"  mean? A  dynamic  Web page is a page whose contents can \r\n change automatically each time the page is viewed. Contrast this with a  static  Web page, such as a simple HTML file, which \r\n looks the same each time it's displayed (at least until the page is next edited). Meanwhile, an  interactive  Web site is a\r\n site that responds to input from its visitors. A Web forum is a good example, users can post new messages to the forum, \r\n which are then displayed on the site for all to see\r\n &lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In lines 2 and 6 we checked if there were cookies available and deleted them if they existed in the browser request. (They were deleted by setting the time argument to a certain time in the past). You might need to refresh your browser to see the result.<\/p>\n<h2>2.\u00a0Summary<\/h2>\n<p>In this example we learnt about cookies, there importance, and how to create and delete them in php. We also learnt about their benefits and drawbacks.<\/p>\n<h2>3.\u00a0Download the source code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: \u00a0<strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/07\/phpcookieexample.zip\">phpcookieexample<\/a><br \/>\n<\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client after a connection), web developers need a way to store user preferences or allow their scripts to remember details about each client. \u00a0Cookies take on to solve this problem. &hellip;<\/p>\n","protected":false},"author":164,"featured_media":930,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-13668","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Php Cookie Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Php Cookie Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-07T13:15:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:49:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"Php Cookie Example\",\"datePublished\":\"2016-07-07T13:15:10+00:00\",\"dateModified\":\"2018-01-09T08:49:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/\"},\"wordCount\":806,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/\",\"name\":\"Php Cookie Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-07-07T13:15:10+00:00\",\"dateModified\":\"2018-01-09T08:49:45+00:00\",\"description\":\"Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/php\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Php Cookie Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Php Cookie Example - Web Code Geeks - 2026","description":"Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/","og_locale":"en_US","og_type":"article","og_title":"Php Cookie Example - Web Code Geeks - 2026","og_description":"Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-07-07T13:15:10+00:00","article_modified_time":"2018-01-09T08:49:45+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"Php Cookie Example","datePublished":"2016-07-07T13:15:10+00:00","dateModified":"2018-01-09T08:49:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/"},"wordCount":806,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/","name":"Php Cookie Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-07-07T13:15:10+00:00","dateModified":"2018-01-09T08:49:45+00:00","description":"Cookies are an important part of php and web development in general. Since http is a stateless protocol (This means that the server forgets each client","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/php\/php-cookie-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"PHP","item":"https:\/\/www.webcodegeeks.com\/category\/php\/"},{"@type":"ListItem","position":3,"name":"Php Cookie Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/13668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=13668"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/13668\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=13668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=13668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=13668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}