src/Session.php
public function install($global = false)
	{
		// Make sure we have a sessions table
		$schema = $this->dbConnection->getSchemaBuilder();
		if (!$schema->hasTable($this->table))
		{
			$schema->create($this->table, function($t)
			{
				$t->string('id')->unique();
				$t->text('payload');
				$t->integer('last_activity');
			});
		}

		// Run the garbage collection
		$this->sessionStore->getHandler()->gc($this->lifetime);

		// Check for our session cookie
		if (isset($_COOKIE[$this->name]))
		{
			// Grab the session id from the cookie
			$cookie_id = $_COOKIE[$this->name];

			// Does the session exist in the db?
			$session = (object) $this->dbConnection
				->table($this->table)
				->find($cookie_id)
			;

			if (isset($session->payload))
			{
				// Set the id of the session
				$this->sessionStore->setId($cookie_id);
			}
			else
			{
				// Set the expired flag
				$this->expired = true;

				// NOTE: We do not need to set the id here.
				// As it has already been set by the constructor of the Store.
			}				
		}

		// Set / reset the session cookie
		if (!isset($_COOKIE[$this->name]) || $this->expired)
		{
			setcookie
			(
				$this->name,
				$this->sessionStore->getId(),
				0,
				$this->path,
				$this->domain,
				$this->secure,
				true
			);
		}

		// Start the session
		$this->sessionStore->start();

		// Save the session on shutdown
		register_shutdown_function([$this->sessionStore, 'save']);

		// Run globalise
		if ($global) $this->globalise();
	}
public function install($global = false)
	{
		// Make sure we have a sessions table
		$schema = $this->dbConnection->getSchemaBuilder();
		if (!$schema->hasTable($this->table))
		{
			$schema->create($this->table, function($t)
			{
				$t->string('id')->unique();
				$t->text('payload');
				$t->integer('last_activity');
			});
		}

		// Run the garbage collection
		$this->sessionStore->getHandler()->gc($this->lifetime);

		// Check for our session cookie
		if (isset($_COOKIE[$this->name]))
		{
			// Grab the session id from the cookie
			$cookie_id = $_COOKIE[$this->name];

			// Does the session exist in the db?
			$session = (object) $this->dbConnection
				->table($this->table)
				->find($cookie_id)
			;

			if (isset($session->payload))
			{
				// Set the id of the session
				$this->sessionStore->setId($cookie_id);
			}
			else
			{
				// Set the expired flag
				$this->expired = true;

				// NOTE: We do not need to set the id here.
				// As it has already been set by the constructor of the Store.
			}				
		}

		// Set / reset the session cookie
		if (!isset($_COOKIE[$this->name]) || $this->expired)
		{
			setcookie
			(
				$this->name,
				$this->sessionStore->getId(),
				0,
				$this->path,
				$this->domain,
				$this->secure,
				true
			);
		}

		// Start the session
		$this->sessionStore->start();

		// Save the session on shutdown
		register_shutdown_function([$this->sessionStore, 'save']);

		// Run globalise
		if ($global) $this->globalise();
	}
Method: install
=========================================================================
Once the container has been configured. Please call this method to
install the session api into your application.

Parameters:
-------------------------------------------------------------------------
- $global: If set to true we will also run globalise after setup.

Returns:
-------------------------------------------------------------------------
void