Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[HttpFoundation] fixed Session serialization
  • Loading branch information
fabpot committed Aug 27, 2010
1 parent 57db35b commit 92f4b92
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Symfony/Component/HttpFoundation/Session.php
Expand Up @@ -18,7 +18,7 @@
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class Session
class Session implements \Serializable
{
protected $storage;
protected $locale;
Expand Down Expand Up @@ -232,12 +232,28 @@ public function hasFlash($name)
return array_key_exists($name, $this->attributes['_flash']);
}

public function __destruct()
public function save()
{
if (true === $this->started) {
$this->attributes['_flash'] = array_diff_key($this->attributes['_flash'], $this->oldFlashes);

$this->storage->write('_symfony2', $this->attributes);
}
}

public function __destruct()
{
$this->save();
}

public function serialize()
{
return serialize(array($this->storage, $this->options));
}

public function unserialize($serialized)
{
list($this->storage, $this->options) = unserialize($serialized);
$this->attributes = array();
$this->started = false;
}
}

0 comments on commit 92f4b92

Please sign in to comment.