{"id":75,"date":"2011-04-09T21:25:50","date_gmt":"2011-04-09T21:25:50","guid":{"rendered":"http:\/\/62.131.51.129\/wordpress\/?p=75"},"modified":"2011-04-09T21:25:50","modified_gmt":"2011-04-09T21:25:50","slug":"creating-a-cookie","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=75","title":{"rendered":"Creating a cookie"},"content":{"rendered":"<p>Cookies are small items that can be written on the hard disk of a client computer. In Google Chrome, these cookies can be found in a binary file. I found this file in &#8220;C:\\Users\\tmaanen.CORP\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cookies&#8221;. <br \/>\nThese files can be written on request of the webserver. I wrote a small PHP programme that writes these cookies on the hard disk of the client. The programme reads as:<\/p>\n<pre>\n?php\nsetcookie(\"cookie[three]\", \"cookiethree\", time() + 1000);\nsetcookie(\"cookie[two]\", \"cookietwo\", time() + 1000);\nsetcookie(\"cookie[one]\", \"cookieone\", time() + 1000);\necho \"Cookie is set - disappears in 1000secs\\n\";    \n?\n<\/pre>\n<p>When this programme was executes on the webserver, a cookie is sent to client computer. There, it can be seen in the options screen that displays cookies:<br \/>\n<img decoding=\"async\" src=\"http:\/\/van-maanen.com\/Cookie.png\" alt=\"Chrome display of cookies\" \/><\/p>\n<p>\nOnce these cookies are stored on the hard disk, we could read them with a programme that is stored on the webserver. An example is given here:<\/p>\n<pre>\nif (isset($_COOKIE['cookie'])) {\n    foreach ($_COOKIE['cookie'] as $name => $value) {\n        $name = htmlspecialchars($name);\n        $value = htmlspecialchars($value);\n        echo \"$name : $value <br \/>\\n\";\n    }\n};\n<\/pre>\n<p>This PHP programme is executed on request from the client computer. This gives a screen like:<br \/>\n<br \/>\n<img decoding=\"async\" src=\"http:\/\/62.131.51.129\/ReadCookie.png\" alt=\"Return Cookies\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cookies are small items that can be written on the hard disk of a client computer. In Google Chrome, these cookies can be found in a binary file. I found this file in &#8220;C:\\Users\\tmaanen.CORP\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cookies&#8221;. These files can be written on request of the webserver. I wrote a small PHP programme that writes these cookies [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-nice-to-know"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=75"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/75\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}