Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon Model not accepting variable(?)

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() which returned pentacore so... what could be the problem?

edited Oct '14

It could be that cookie's decryption adds extra trailing spaces so you have probably to do:

$login = $this->cookies->get('login');
$loggedinas = trim($login->getValue());
$user = Users::findFirstByUsername($loggedinas)


thank you, that solved it