# SessionHandlerProxy

class SessionHandlerProxy extends AbstractProxy implements SessionHandlerInterface

## Properties

`protected bool` | `$wrapper` | Flag if handler wraps an internal PHP session handler (using \SessionHandler). | from AbstractProxy
`protected string` | `$saveHandlerName` |  | from AbstractProxy
`protected` | `$handler` |  |

## Methods

`public` | `string` | `getSaveHandlerName()` | Gets the session.save_handler name. | from AbstractProxy
`public` | `bool` | `isSessionHandlerInterface()` | Is this proxy handler and instance of \SessionHandlerInterface. | from AbstractProxy
`public` | `bool` | `isWrapper()` | Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. | from AbstractProxy
`public` | `bool` | `isActive()` | Has a session started? | from AbstractProxy
`public` | `string` | `getId()` | Gets the session ID. | from AbstractProxy
`public` | `` | `setId(string $id)` | Sets the session ID. | from AbstractProxy
`public` | `string` | `getName()` | Gets the session name. | from AbstractProxy
`public` | `` | `setName(string $name)` | Sets the session name. | from AbstractProxy
`public` | `` | `__construct(SessionHandlerInterface $handler)` | No description |
`public` | `SessionHandlerInterface` | `getHandler()` | No description |
`public` | `` | `open($savePath, $sessionName)` | {@inheritdoc} |
`public` | `` | `close()` | {@inheritdoc} |
`public` | `` | `read($sessionId)` | {@inheritdoc} |
`public` | `` | `write($sessionId, $data)` | {@inheritdoc} |
`public` | `` | `destroy($sessionId)` | {@inheritdoc} |
`public` | `` | `gc($maxlifetime)` | {@inheritdoc} |

## Details

in AbstractProxy at line 36

### `getSaveHandlerName()`

`public string getSaveHandlerName()`

Gets the session.save_handler name.

#### Return Value

`string` |

in AbstractProxy at line 46

### `isSessionHandlerInterface()`

`public bool isSessionHandlerInterface()`

Is this proxy handler and instance of \SessionHandlerInterface.

#### Return Value

`bool` |

in AbstractProxy at line 56

### `isWrapper()`

`public bool isWrapper()`

Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.

#### Return Value

`bool` |

in AbstractProxy at line 66

### `isActive()`

`public bool isActive()`

Has a session started?

#### Return Value

`bool` |

in AbstractProxy at line 76

### `getId()`

`public string getId()`

Gets the session ID.

#### Return Value

`string` |

in AbstractProxy at line 88

### `setId()`

`public setId(string $id)`

Sets the session ID.

#### Parameters

`string` | `$id` |

#### Exceptions

LogicException |

in AbstractProxy at line 102

### `getName()`

`public string getName()`

Gets the session name.

#### Return Value

`string` |

in AbstractProxy at line 114

### `setName()`

`public setName(string $name)`

Sets the session name.

#### Parameters

`string` | `$name` |

#### Exceptions

LogicException |

at line 21

### `__construct()`

`public __construct(SessionHandlerInterface $handler)`

#### Parameters

`SessionHandlerInterface` | `$handler` |

at line 31

### `getHandler()`

`public SessionHandlerInterface getHandler()`

#### Return Value

`SessionHandlerInterface` |

at line 41

### `open()`

`public open($savePath, $sessionName)`

{@inheritdoc}

#### Parameters

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

at line 49

### `close()`

`public close()`

{@inheritdoc}

at line 57

### `read()`

`public read($sessionId)`

{@inheritdoc}

#### Parameters

| `$sessionId` |

at line 65

### `write()`

`public write($sessionId, $data)`

{@inheritdoc}

#### Parameters

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

at line 73

### `destroy()`

`public destroy($sessionId)`

{@inheritdoc}

#### Parameters

| `$sessionId` |

at line 81

### `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\Proxy;

    /**
     * @author Drak <drak@zikula.org>
     */
    class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface
    {
        protected $handler;

        public function __construct(\SessionHandlerInterface $handler)
        {
            $this->handler = $handler;
            $this->wrapper = ($handler instanceof \SessionHandler);
            $this->saveHandlerName = $this->wrapper ? ini_get('session.save_handler') : 'user';
        }

        /**
         * @return \SessionHandlerInterface
         */
        public function getHandler()
        {
            return $this->handler;
        }

        // \SessionHandlerInterface

        /**
         * {@inheritdoc}
         */
        public function open($savePath, $sessionName)
        {
            return (bool) $this->handler->open($savePath, $sessionName);
        }

        /**
         * {@inheritdoc}
         */
        public function close()
        {
            return (bool) $this->handler->close();
        }

        /**
         * {@inheritdoc}
         */
        public function read($sessionId)
        {
            return (string) $this->handler->read($sessionId);
        }

        /**
         * {@inheritdoc}
         */
        public function write($sessionId, $data)
        {
            return (bool) $this->handler->write($sessionId, $data);
        }

        /**
         * {@inheritdoc}
         */
        public function destroy($sessionId)
        {
            return (bool) $this->handler->destroy($sessionId);
        }

        /**
         * {@inheritdoc}
         */
        public function gc($maxlifetime)
        {
            return (bool) $this->handler->gc($maxlifetime);
        }
    }