Skip to content

Commit

Permalink
Add in depth to set function to allow for array merge and arrays to b…
Browse files Browse the repository at this point in the history
…e set to sessions.
  • Loading branch information
Ashley Hutson authored and Ashley Hutson committed May 30, 2017
1 parent 47e9763 commit f9f26f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/SlimSession/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ public function get($key, $default = null)
*/
public function set($key, $value)
{
$_SESSION[$key] = $value;
if (is_array($value) && isset($_SESSION[$key]) && is_array($_SESSION[$key])) {
$_SESSION[$key] = array_merge($_SESSION[$key], $value);
return $this;
}

$_SESSION[$key] = $value;
return $this;
}

Expand Down

0 comments on commit f9f26f8

Please sign in to comment.