# NullSessionHandler

class NullSessionHandler extends AbstractSessionHandler

Can be used in unit testing or in a situations where persisted sessions are not desired.

## Methods

`public` | `` | `open($savePath, $sessionName)` | {@inheritdoc} | from AbstractSessionHandler
`protected` | `string` | `doRead(string $sessionId)` | No description |
`protected` | `bool` | `doWrite(string $sessionId, string $data)` | No description |
`protected` | `bool` | `doDestroy(string $sessionId)` | No description |
`public` | `` | `validateId($sessionId)` | {@inheritdoc} |
`public` | `` | `read($sessionId)` | {@inheritdoc} | from AbstractSessionHandler
`public` | `` | `write($sessionId, $data)` | {@inheritdoc} | from AbstractSessionHandler
`public` | `` | `destroy($sessionId)` | {@inheritdoc} | from AbstractSessionHandler
`public` | `` | `close()` | {@inheritdoc} |
`public` | `` | `updateTimestamp($sessionId, $data)` | {@inheritdoc} |
`public` | `` | `gc($maxlifetime)` | {@inheritdoc} |

## Details

in AbstractSessionHandler at line 32

### `open()`

`public open($savePath, $sessionName)`

{@inheritdoc}

#### Parameters

| `$savePath` |
| `$sessionName` |

at line 40

### `doRead()`

`protected string doRead(string $sessionId)`

#### Parameters

`string` | `$sessionId` |

#### Return Value

`string` |

at line 56

### `doWrite()`

`protected bool doWrite(string $sessionId, string $data)`

#### Parameters

`string` | `$sessionId` |
`string` | `$data` |

#### Return Value

`bool` |

at line 64

### `doDestroy()`

`protected bool doDestroy(string $sessionId)`

#### Parameters

`string` | `$sessionId` |

#### Return Value

`bool` |

at line 32

### `validateId()`

`public validateId($sessionId)`

{@inheritdoc}

#### Parameters

| `$sessionId` |

in AbstractSessionHandler at line 78

### `read()`

`public read($sessionId)`

{@inheritdoc}

#### Parameters

| `$sessionId` |

in AbstractSessionHandler at line 101

### `write()`

`public write($sessionId, $data)`

{@inheritdoc}

#### Parameters

| `$sessionId` |
| `$data` |

in AbstractSessionHandler at line 118

### `destroy()`

`public destroy($sessionId)`

{@inheritdoc}

#### Parameters

| `$sessionId` |

at line 24

### `close()`

`public close()`

{@inheritdoc}

at line 48

### `updateTimestamp()`

`public updateTimestamp($sessionId, $data)`

{@inheritdoc}

#### Parameters

| `$sessionId` |
| `$data` |

at line 72

### `gc()`

`public gc($maxlifetime)`

{@inheritdoc}

#### Parameters

| `$maxlifetime` |

## Source code

    <?php

    /*
     * This file is part of the Symfony package.
     *
     * (c) Fabien Potencier <fabien@symfony.com>
     *
     * For the full copyright and license information, please view the LICENSE
     * file that was distributed with this source code.
     */

    namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;

    /**
     * Can be used in unit testing or in a situations where persisted sessions are not desired.
     *
     * @author Drak <drak@zikula.org>
     */
    class NullSessionHandler extends AbstractSessionHandler
    {
        /**
         * {@inheritdoc}
         */
        public function close()
        {
            return true;
        }

        /**
         * {@inheritdoc}
         */
        public function validateId($sessionId)
        {
            return true;
        }

        /**
         * {@inheritdoc}
         */
        protected function doRead($sessionId)
        {
            return '';
        }

        /**
         * {@inheritdoc}
         */
        public function updateTimestamp($sessionId, $data)
        {
            return true;
        }

        /**
         * {@inheritdoc}
         */
        protected function doWrite($sessionId, $data)
        {
            return true;
        }

        /**
         * {@inheritdoc}
         */
        protected function doDestroy($sessionId)
        {
            return true;
        }

        /**
         * {@inheritdoc}
         */
        public function gc($maxlifetime)
        {
            return true;
        }
    }