An Internal Server Error Occurred

Hello,

since i inserted
"function beforeRender(Event $event){
$this->set(‘authuser1’, $this->Auth->user());
}"
into AppController my Error Debug does’nt work… I get this:

An Internal Server Error Occurred

only…

If i commented this, it works.

Can someone help me?

THX
Ole

Do you have an error controller? Does it extends AppController?

AFAIK Error controller does not load any component by default (including Auth) so you try to access Auth in beforeRender and is not loaded, php throws a “Cant get property user of null” exception

You might want to load AuthComponent in you ErrorController or add an if to check if Auth is loaded (or a try?)

1 Like

Do you have a

use Cake\Event\Event;

at the beginning of your class-file?

hi,

thanks for helping.

I have to load Auth-Component into my AppController. Now it works fine!

Ole

i have loaded auth component still it does not work

Please start a different thread and show code for the community to look at.