# SessionHandler

> SessionHandler implements an SessionHandlerInterface for handling yii\web\Session with custom session storage.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [web](/docs/api/yii/web/index.md) › SessionHandler

| class | `yii\web\SessionHandler` |
| --- | --- |
| Implements | [`SessionHandlerInterface`](https://www.php.net/manual/en/class.sessionhandlerinterface.php) |
| Since | 2.0.52 |
| Source | [`framework/web/SessionHandler.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/web/SessionHandler.php#L19) |

SessionHandler implements an [`SessionHandlerInterface`](https://www.php.net/manual/en/class.sessionhandlerinterface.php) for handling [`Session`](/docs/api/yii/web/session/index.md) with custom session storage.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) |  | `SessionHandler` |
| [`close()`](#method-close) |  | `SessionHandler` |
| [`destroy()`](#method-destroy) |  | `SessionHandler` |
| [`gc()`](#method-gc) |  | `SessionHandler` |
| [`open()`](#method-open) |  | `SessionHandler` |
| [`read()`](#method-read) |  | `SessionHandler` |
| [`write()`](#method-write) |  | `SessionHandler` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(yii\web\Session $session)
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$session` | [`Session`](/docs/api/yii/web/session/index.md) |  |

### close() <span id="method-close"></span>

```php
public function close(): bool
```

**Returns**

`bool`

### destroy() <span id="method-destroy"></span>

```php
public function destroy(mixed $id): bool
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `mixed` |  |

**Returns**

`bool`

### gc() <span id="method-gc"></span>

```php
public function gc(mixed $max_lifetime): mixed
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$max_lifetime` | `mixed` |  |

**Returns**

`mixed`

### open() <span id="method-open"></span>

```php
public function open(mixed $path, mixed $name): bool
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$path` | `mixed` |  |
| `$name` | `mixed` |  |

**Returns**

`bool`

### read() <span id="method-read"></span>

```php
public function read(mixed $id): mixed
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `mixed` |  |

**Returns**

`mixed`

### write() <span id="method-write"></span>

```php
public function write(mixed $id, mixed $data): bool
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `mixed` |  |
| `$data` | `mixed` |  |

**Returns**

`bool`