{"id":75,"date":"2011-09-28T01:21:43","date_gmt":"2011-09-28T01:21:43","guid":{"rendered":"http:\/\/info.ffteixeira.net\/2011\/09\/28\/cake-1-2-auth-is-someone-logged-in\/"},"modified":"2011-09-28T01:21:43","modified_gmt":"2011-09-28T01:21:43","slug":"cake-1-2-auth-is-someone-logged-in","status":"publish","type":"post","link":"https:\/\/blog.ffteixeira.net\/?p=75","title":{"rendered":"Cake 1.2 Auth &#8211; Is someone logged in?"},"content":{"rendered":"<p>The Auth login stores the user information in the Session \u00a0(with Auth\u00a0 key). The Auth-&gt;user() is actually a wrapper function to the session\u00a0 Auth.User key. The Auth logout function delete the informations from the session.<\/p>\n<p><!--more--><br \/>\nThe Auth login stores the user information in the Session \u00a0(with Auth\u00a0 key). The Auth-&gt;user() is actually a wrapper function to the session\u00a0 Auth.User key. The Auth logout function delete the informations from the session.<\/p>\n<p><!--more-->Knowing this, you can use the Session component in controllers and the session helper in views to detect the login status.<\/p>\n<p><strong><em>in controllers:<\/em><\/strong><\/p>\n<p>$this-&gt;Session-&gt;check(&#8216;Auth.User.id&#8217;) will return true if the user is\u00a0 logged, you can also use $this-&gt;Auth-&gt;user(&#8216;id&#8217;).<\/p>\n<p><strong><em>in views<\/em><\/strong><\/p>\n<p>$session-&gt;check(&#8216;Auth.User.id&#8217;) will tell you if a user is logged, and you can user $session-&gt;read(&#8216;Auth.User&#8217;) to retrieve the user&#8217;s information.<\/p>\n<p><a title=\"credits\" href=\"http:\/\/groups.google.com\/group\/cake-php\/browse_thread\/thread\/ee9456de93d2eece\/cff6fe580d13622b?lnk=gst&amp;q=auth\" target=\"_blank\" rel=\"noopener noreferrer\">Credits <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Auth login stores the user information in the Session \u00a0(with Auth\u00a0 key). The Auth-&gt;user() is actually a wrapper function to the session\u00a0 Auth.User key. The Auth logout function delete the informations from the session.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=75"}],"version-history":[{"count":0,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/75\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}