Skip to content

Commit

Permalink
cleaning up some code and re-imlementing Session::id()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 17, 2014
1 parent 072779e commit b96107b
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions src/Network/Session.php
Expand Up @@ -36,20 +36,6 @@
*/
class Session {

/**
* Path to where the session is active.
*
* @var string
*/
public static $path = '/';

/**
* Current Session id
*
* @var string
*/
public static $id = null;

/**
* Session cookie name
*
Expand All @@ -61,7 +47,6 @@ class Session {

protected $_started;

protected $_id;

public static function create($sessionConfig = []) {
if (isset($sessionConfig['defaults'])) {
Expand Down Expand Up @@ -117,7 +102,6 @@ protected static function _defaultConfig($name) {
'timeout' => 240,
'ini' => array(
'session.use_trans_sid' => 0,
'session.cookie_path' => static::$path
)
),
'cake' => array(
Expand All @@ -129,7 +113,6 @@ protected static function _defaultConfig($name) {
'url_rewriter.tags' => '',
'session.serialize_handler' => 'php',
'session.use_cookies' => 1,
'session.cookie_path' => static::$path,
'session.save_path' => TMP . 'sessions',
'session.save_handler' => 'files'
)
Expand All @@ -142,7 +125,6 @@ protected static function _defaultConfig($name) {
'session.use_trans_sid' => 0,
'url_rewriter.tags' => '',
'session.use_cookies' => 1,
'session.cookie_path' => static::$path,
'session.save_handler' => 'user',
),
'handler' => array(
Expand All @@ -158,7 +140,6 @@ protected static function _defaultConfig($name) {
'session.use_trans_sid' => 0,
'url_rewriter.tags' => '',
'session.use_cookies' => 1,
'session.cookie_path' => static::$path,
'session.save_handler' => 'user',
'session.serialize_handler' => 'php',
),
Expand Down Expand Up @@ -353,15 +334,12 @@ public function write($name, $value = null) {
* @param string $id Id to replace the current session id
* @return string Session id
*/
public static function id($id = null) {
public function id($id = null) {
if ($id) {
static::$id = $id;
session_id(static::$id);
}
if (static::started()) {
return session_id();
session_id($id);
}
return static::$id;

return session_id();
}

/**
Expand Down Expand Up @@ -427,8 +405,7 @@ public function clear() {
* @return bool
*/
protected function _hasSession() {
$present = !ini_get('session.use_cookies') || isset($_COOKIE[session_name()]);
return $this->started() || $present;
return !ini_get('session.use_cookies') || isset($_COOKIE[session_name()]);
}

/**
Expand Down

0 comments on commit b96107b

Please sign in to comment.