Line 145: if ($this->login_ticket_timestamp >= (time() + 7200)) { The timestamp is always expired this way. It should be: if ($this->login_ticket_timestamp <= (time() - 7200)) {