* // Retrieve the session instance and get an item * Session::instance()->get('name'); * * // Retrieve the session instance and place an item in the session * Session::instance()->put('name', 'Taylor'); * * * @return Payload */ public static function instance() { if (static::started()) return static::$instance; throw new \Exception("A driver must be set before using the session."); } /** * Determine if session handling has been started for the request. * * @return bool */ public static function started() { return ! is_null(static::$instance); } /** * Magic Method for calling the methods on the session singleton instance. * * * // Retrieve a value from the session * $value = Session::get('name'); * * // Write a value to the session storage * $value = Session::put('name', 'Taylor'); * * // Equivalent statement using the "instance" method * $value = Session::instance()->put('name', 'Taylor'); * */ public static function __callStatic($method, $parameters) { return call_user_func_array(array(static::instance(), $method), $parameters); } }