/** * Set a flash message to the queue * * @param string $key Flash type to set * @param string $message Flash Message * @throws \Exception * @return bool */ public function setFlash($key, $message) { if (!Session::has('flashMessages')) { return false; } if (!isset($key) || !isset($message[0])) { return false; } // Verify $key is a valid message type or not if (!in_array($key, $this->validFlashTypes)) { throw new \Exception('"' . strip_tags($key) . '" is not a valid message type!'); } // If the flash session array doesn't exist, make it if (!array_key_exists($key, Session::get('flashMessages'))) { Session::set('flashMessages', array($key => array())); } Session::set('flashMessages', array($key => array($message))); return true; }
/** * We will set session * * @return mixed */ private function setSession() { $primaryKey = null; $data = array(); $primaryKey = self::$user[0]->getPrimaryKey(); $data[$primaryKey] = self::$user[0]->{$primaryKey}; foreach (self::$user[0]->getAttributes() as $key => $val) { $data[$key] = $val; } $data['isLoggedIn'] = true; $data['flashMsg'] = static::$msg . ucfirst($this->username); Session::set('auth:' . trim($this->table), $data); return true; }