> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lunarphp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Storefront Session

## Overview

The storefront session facade is a provided to help keep certain resources your storefront needs set, such as channel, customer group etc.

```php theme={null}
use Lunar\Facades\StorefrontSession;
```

## Channels

### Initialise the Channel

This will set the Channel based on what's been previously set, otherwise it will use the default.

```php theme={null}
StorefrontSession::initChannel();
```

<Info>
  This is automatically called when using the facade.
</Info>

### Set the Channel

```php theme={null}
$channel = new Channel([
    'name' => 'Webstore',
    'handle' => 'webstore',
]);

StorefrontSession::setChannel($channel);
StorefrontSession::setChannel('webstore');
```

### Get the Channel

```php theme={null}
StorefrontSession::getChannel();
```

## Customer Groups

### Initialise the Customer Groups

This will set the Customer Groups based on what's been previously set (from the session), otherwise it will use the default record.

```php theme={null}
StorefrontSession::initCustomerGroups();
```

<Info>
  This is automatically called when using the facade.
</Info>

### Set the Customer Groups

```php theme={null}
$customerGroup = new CustomerGroup([
    'name' => 'Retail',
    'handle' => 'retail',
]);

// Set multiple customer groups
StorefrontSession::setCustomerGroups(collect($customerGroup));

// Set a single customer group, under the hood this will just call `setCustomerGroups`.
StorefrontSession::setCustomerGroup($customerGroup);
```

### Get the Customer Groups

```php theme={null}
StorefrontSession::getCustomerGroups();
```

## Customer

### Initialise the Customer

This will set the Customer based on what's been previously set (from the session), otherwise it will retrieve the latest customer attached with the logged in user.

```php theme={null}
StorefrontSession::initCustomer();
```

<Info>
  This is automatically called when using the facade.
</Info>

### Set the Customer

```php theme={null}
$customer = /** your store logic to determine current customer */ ;

StorefrontSession::setCustomer($customer);
```

### Get the Customer

```php theme={null}
StorefrontSession::getCustomer();
```

## Currencies

### Set the Currency

```php theme={null}
$currency = new Currency([
    'name' => 'US Dollars',
    'code' => 'USD',
    // ...
]);

StorefrontSession::setCurrency($currency);
StorefrontSession::setCurrency('USD');
```

### Get the Currency

```php theme={null}
StorefrontSession::getCurrency();
```
