{"id":113,"date":"2018-02-14T17:03:44","date_gmt":"2018-02-14T16:03:44","guid":{"rendered":"http:\/\/www.contentecontent.com\/blog\/?p=113"},"modified":"2018-02-14T17:03:44","modified_gmt":"2018-02-14T16:03:44","slug":"set-cookie-in-htaccess-kills-php-session","status":"publish","type":"post","link":"https:\/\/www.contentecontent.com\/blog\/2018\/02\/set-cookie-in-htaccess-kills-php-session\/","title":{"rendered":"Set-Cookie in .htaccess kills PHP session"},"content":{"rendered":"<p>Just spent too much time on finding out why sessions didn&#8217;t work on a particular site. To be precise: the PHP session cookie was not sent.<\/p>\n<p>Turned out that there was a line in the site&#8217;s .htaccess that also set a temporary cookie:<\/p>\n<pre><code>&lt;FilesMatch \"\\.php$\"&gt;\nHeader set Set-Cookie \"myCookie=1; path=\/;\"\n&lt;\/FilesMatch&gt;\n<\/code><\/pre>\n<p>All was fine when I changed <code>set<\/code> into <code>add<\/code>:<\/p>\n<pre><code>&lt;FilesMatch \"\\.php$\"&gt;\nHeader add Set-Cookie \"myCookie=1; path=\/;\"\n&lt;\/FilesMatch&gt;\n<\/code><\/pre>\n<p>Cheers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just spent too much time on finding out why sessions didn&#8217;t work on a particular site. To be precise: the PHP session cookie was not sent. Turned out that there was a line in the site&#8217;s .htaccess that also set a temporary cookie: &lt;FilesMatch &#8220;\\.php$&#8221;&gt; Header set Set-Cookie &#8220;myCookie=1; path=\/;&#8221; &lt;\/FilesMatch&gt; All was fine when &hellip; <a href=\"https:\/\/www.contentecontent.com\/blog\/2018\/02\/set-cookie-in-htaccess-kills-php-session\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Set-Cookie in .htaccess kills PHP session<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[20,7],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-misc","tag-cookies","tag-php"],"_links":{"self":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":1,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/113\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}