We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is how I have setup my AppController.php, but it is giving error
<?php namespace App\Controller; use Cake\Controller\Controller; use Cake\Event\Event; use Cake\Core\Configure; class AppController extends Controller { public function initialize() { parent::initialize(); $this->loadComponent('RequestHandler'); $this->loadComponent('Flash'); $this->loadComponent('Auth', [ 'loginRedirect' => [ 'controller' => 'Dashboard', 'action' => 'index' ], 'logoutRedirect' => [ 'controller' => 'Pages', 'action' => 'home' ], 'authenticate' => [ 'Form' => [ 'finder' => 'auth', ], 'Xety/Cake3CookieAuth.Cookie' => [ 'cookie' => [ 'name' => 'CookieAuth' ] ] ] ]); //$this->loadComponent('Security'); //$this->loadComponent('Csrf'); } public function beforeRender(Event $event) { $this->loadComponent('Auth'); // login using cookies if (!$this->Auth->user('id') && $this->Cookie->read('CookieAuth')) { $user = $this->Auth->identify(); if ($user) { $this->Auth->setUser($user); } else { $this->Cookie->delete('CookieAuth'); } } // set logged in user data to render in view files if ($this->Auth->user('id')) { $this->set('AUTH_USER', $this->Auth->user()); } if (!array_key_exists('_serialize', $this->viewVars) && in_array($this->response->type(), ['application/json', 'application/xml']) ) { $this->set('_serialize', true); } } }
Error getting is
Fatal error: Uncaught Error: Call to a member function read() on boolean in /var/www/html/emeet.com/emeet_cake/src/Controller/AppController.php:46
on removing $this->Cookie->read('CookieAuth'), error jumped to next Cookie->delete line
$this->Cookie->read('CookieAuth')
Cookie->delete
The text was updated successfully, but these errors were encountered:
Better late than never, but it might be useful for someone else. You forgot to add public $components = ['Cookie']; in your code.
public $components = ['Cookie'];
Sorry, something went wrong.
No branches or pull requests
This is how I have setup my AppController.php, but it is giving error
Error getting is
on removing
$this->Cookie->read('CookieAuth')
, error jumped to nextCookie->delete
lineThe text was updated successfully, but these errors were encountered: