{"id":1962,"date":"2021-11-14T21:02:33","date_gmt":"2021-11-14T12:02:33","guid":{"rendered":"https:\/\/417.run\/?p=1962"},"modified":"2021-11-14T21:09:40","modified_gmt":"2021-11-14T12:09:40","slug":"cakephp4-session","status":"publish","type":"post","link":"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-session\/","title":{"rendered":"CakePHP4\u3067\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4fdd\u5b58\u30fb\u8aad\u307f\u51fa\u3057"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_17 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u6b21<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-session\/#%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83%BC%E3%83%A9%E3%83%BCController%E3%81%8B%E3%82%89%E3%82%BB%E3%83%83%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%BF%E3%81%86\" title=\"\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc(Controller)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\">\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc(Controller)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-session\/#%E3%83%98%E3%83%AB%E3%83%91%E3%83%BCHelper%E3%81%8B%E3%82%89%E3%82%BB%E3%83%83%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%BF%E3%81%86\" title=\"\u30d8\u30eb\u30d1\u30fc(Helper)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\">\u30d8\u30eb\u30d1\u30fc(Helper)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-session\/#%E4%BF%9D%E5%AD%98\" title=\"\u4fdd\u5b58\">\u4fdd\u5b58<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-session\/#%E8%AA%AD%E3%81%BF%E5%87%BA%E3%81%97\" title=\"\u8aad\u307f\u51fa\u3057\">\u8aad\u307f\u51fa\u3057<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-session\/#%E5%89%8A%E9%99%A4\" title=\"\u524a\u9664\">\u524a\u9664<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-session\/#key%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6\" title=\"key\u306b\u3064\u3044\u3066\">key\u306b\u3064\u3044\u3066<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83%BC%E3%83%A9%E3%83%BCController%E3%81%8B%E3%82%89%E3%82%BB%E3%83%83%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%BF%E3%81%86\"><\/span>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc(Controller)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-php\">$session = $this-&gt;getRequest()-&gt;getSession();<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E3%83%98%E3%83%AB%E3%83%91%E3%83%BCHelper%E3%81%8B%E3%82%89%E3%82%BB%E3%83%83%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%BF%E3%81%86\"><\/span>\u30d8\u30eb\u30d1\u30fc(Helper)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-php\">$session = $this-&gt;getView()-&gt;getRequest()-&gt;getSession();<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E4%BF%9D%E5%AD%98\"><\/span>\u4fdd\u5b58<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-php\">$data = &#039;\u305b\u3063\u3057\u3087\u3093\u3093\u3093\u3093\uff01&#039;;\n$session-&gt;write(&#039;key&#039;, $data);<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E8%AA%AD%E3%81%BF%E5%87%BA%E3%81%97\"><\/span>\u8aad\u307f\u51fa\u3057<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-php\">$data = $session-&gt;read(&#039;key&#039;); \/\/ \u305b\u3063\u3057\u3087\u3093\u3093\u3093\u3093\uff01<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E5%89%8A%E9%99%A4\"><\/span>\u524a\u9664<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-php\">$session-&gt;delete(&#039;key&#039;);<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"key%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6\"><\/span>key\u306b\u3064\u3044\u3066<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u30c9\u30c3\u30c8\u533a\u5207\u308a\u3067\u4fdd\u5b58\u304c\u3067\u304d\u308b<\/p>\n<pre><code class=\"language-php\">$session-&gt;write(&#039;Some.key&#039;, $data);<\/code><\/pre>\n<a href=\"https:\/\/book.cakephp.org\/3\/ja\/development\/sessions.html\" target=\"_blank\" rel=\"external noopener noreferrer\">\u516c\u5f0f<\/a>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21 \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc(Controller)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u30d8\u30eb\u30d1\u30fc(Helper)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u4fdd\u5b58\u8aad\u307f\u51fa\u3057\u524a\u9664key\u306b\u3064\u3044\u3066 \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc(Controller)\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3046 $session = &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"class_list":{"0":"post-1962","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-cakephp4","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts\/1962"}],"collection":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/comments?post=1962"}],"version-history":[{"count":5,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts\/1962\/revisions"}],"predecessor-version":[{"id":1967,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts\/1962\/revisions\/1967"}],"wp:attachment":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/media?parent=1962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/categories?post=1962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/tags?post=1962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}