# How can we allow a function before login in cakephp?

**URL:** <https://discourse.cakephp.org/t/how-can-we-allow-a-function-before-login-in-cakephp/6560>\
**Category:** Need Help\
**Created:** [August 30, 2019, 1:56pm UTC](https://discourse.cakephp.org/t/how-can-we-allow-a-function-before-login-in-cakephp/6560 "2019-08-30T13:56:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manjukashyap](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@Manjukashyap](https://discourse.cakephp.org/u/Manjukashyap)\
**Post date:** [August 30, 2019, 1:56pm UTC](https://discourse.cakephp.org/t/how-can-we-allow-a-function-before-login-in-cakephp/6560/1 "2019-08-30T13:56:48Z")

</div>

How can we allow a function before login in cakephp?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [August 30, 2019, 3:36pm UTC](https://discourse.cakephp.org/t/how-can-we-allow-a-function-before-login-in-cakephp/6560/2 "2019-08-30T15:36:35Z")

</div>

What do you mean by this? Allow a controller action to be used by people who aren’t logged in? The answer to that would depend on whether you’re using the Auth component or the plugin.

---

<div class="post-metadata">

**Author:** ![kailashdesk](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kailashdesk/32/1493_2.png) [@kailashdesk](https://discourse.cakephp.org/u/kailashdesk)\
**Post date:** [August 30, 2019, 4:03pm UTC](https://discourse.cakephp.org/t/how-can-we-allow-a-function-before-login-in-cakephp/6560/3 "2019-08-30T16:03:05Z")

</div>

You can allow any methods without login with the following code in the controller:

public function initialize() {  
parent::initialize ();  
$this-\>Auth-\>allow ( [  
‘logout’  
] );  
}

For more information [click Making Actions Public](https://book.cakephp.org/3.0/en/controllers/components/authentication.html#making-actions-public).
