4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider
;
14 use Symfony\Component\HttpFoundation\Session\Session
;
17 * This provider uses a Symfony2 Session object to retrieve the user's
20 * @see DefaultCsrfProvider
22 * @author Bernhard Schussek <bschussek@gmail.com>
24 class SessionCsrfProvider
extends DefaultCsrfProvider
27 * The user session from which the session ID is returned
33 * Initializes the provider with a Session object and a secret value.
35 * A recommended value for the secret is a generated value with at least
36 * 32 characters and mixed letters, digits and special characters.
38 * @param Session $session The user session
39 * @param string $secret A secret value included in the CSRF token
41 public function __construct(Session
$session, $secret)
43 parent
::__construct($secret);
45 $this->session
= $session;
51 protected function getSessionId()
53 $this->session
->start();
55 return $this->session
->getId();