Skip to content

Commit

Permalink
[HttpFoundation] added a way to clear the session attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Oct 19, 2010
1 parent 94347f7 commit 0fc6b15
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/Symfony/Component/HttpFoundation/Session.php
Expand Up @@ -153,13 +153,30 @@ public function remove($name)
if (false === $this->started) {
$this->start();
}

if (array_key_exists($name, $this->attributes)) {
unset($this->attributes[$name]);
}
}

/**
* Clears all attributes.
*/
public function clear()
{
if (false === $this->started) {
$this->start();
}

$this->attributes = array();
}

/**
* Invalidates the current session.
*/
public function invalidate()
{
$this->clear();
$this->storage->regenerate();
}

Expand Down Expand Up @@ -240,7 +257,9 @@ public function hasFlash($name)
public function save()
{
if (true === $this->started) {
$this->attributes['_flash'] = array_diff_key($this->attributes['_flash'], $this->oldFlashes);
if (isset($this->attributes['_flash'])) {
$this->attributes['_flash'] = array_diff_key($this->attributes['_flash'], $this->oldFlashes);
}
$this->storage->write('_symfony2', $this->attributes);
}
}
Expand Down
Expand Up @@ -149,7 +149,6 @@ public function regenerate($destroy = false)
return;
}

// regenerate a new session id once per object
session_regenerate_id($destroy);

self::$sessionIdRegenerated = true;
Expand Down

0 comments on commit 0fc6b15

Please sign in to comment.