public function generateToken($userId, $ipAddress = '') { $this->set_variable('userId', $userId); $this->delete(); $token = authaccess::getRandomToken(authaccess::TOKEN_LENGTH); $this->set_variable('userId', $userId); $this->set_variable('authToken', $token); $this->set_variable('date', gmdate("Y-m-d H:i:s")); $this->set_variable('ipAddress', $ipAddress); $this->createNew(); return $token; }