I have a trouble when i try to verify if a user exists in the database.
$login = $this->cookies->get('login');
$loggedinas = $login->getValue();
$user = Users::findFirstByUsername($loggedinas)
This returns:
PHP Notice: Trying to get property of non-object in /public_html/app/views/charactersheets/create.phtml on line 27, referer: localhost/charactersheets
However if i use this:
$user = Users::findFirstByUsername("pentacore")
it works, and i've checked so that the cookie contains the right username with var_dump($loggedinas) (returns string(32) "pentacore", thank you silkfire) which returned pentacore so... what could be the problem?
From Phalcon @ Phalcon Framework Forum:
It could be that cookie's decryption adds extra trailing spaces so you have to probably do:
$login = $this->cookies->get('login');
$loggedinas = trim($login->getValue());
$user = Users::findFirstByUsername($loggedinas)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.