Skip to content

Commit

Permalink
Added methods to the Session class.
Browse files Browse the repository at this point in the history
  • Loading branch information
feuzeu committed Mar 19, 2017
1 parent c358ae1 commit 93a2628
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ public function __construct()
$this->xSession = new SessionManager();
}

/**
* Get the current session id
*
* @return string The session id
*/
public function getId()
{
return $this->xSession->getId();
}

/**
* Generate a new session id
*
* @param bool $bDeleteData Whether to delete data from the previous session
*
* @return void
*/
public function newId($bDeleteData = false)
{
$this->xSession->migrate($bDeleteData);
}

/**
* Save data in the session
*
Expand Down Expand Up @@ -53,6 +75,38 @@ public function has($sKey)
*/
public function get($sKey, $xDefault = null)
{
return $this->has($sKey) ? $this->xSession->get($sKey) : $xDefault;
return $this->xSession->get($sKey, $xDefault);
}

/**
* Get all data in the session
*
* @return array An array of all data in the session
*/
public function all()
{
return $this->xSession->all();
}

/**
* Delete a session key and its data
*
* @param string $sKey The session key
*
* @return void
*/
public function delete($sKey)
{
$this->xSession->remove($sKey);
}

/**
* Delete all data in the session
*
* @return void
*/
public function clear()
{
$this->xSession->clear();
}
}

0 comments on commit 93a2628

Please sign in to comment.