Symfony\Component\HttpFoundation\Session::start PHP Method

start() public method

Starts the session storage.
public start ( )
    public function start()
    {
        if (true === $this->started) {
            return;
        }

        $this->storage->start();

        $attributes = $this->storage->read('_symfony2');

        if (isset($attributes['attributes'])) {
            $this->attributes = $attributes['attributes'];
            $this->flashes = $attributes['flashes'];
            $this->locale = $attributes['locale'];
            $this->setPhpDefaultLocale($this->locale);

            // flag current flash messages to be removed at shutdown
            $this->oldFlashes = $this->flashes;
        }

        $this->started = true;
    }

Usage Example

Example #1
0
 /**
  * Returns the ID of the user session
  *
  * Automatically starts the session if necessary.
  *
  * @return string  The session ID
  */
 protected function getSessionId()
 {
     $this->session->start();
     return $this->session->getId();
 }