diff --git a/src/EpiSession.php b/src/EpiSession.php index ff001da..62e17f3 100644 --- a/src/EpiSession.php +++ b/src/EpiSession.php @@ -55,7 +55,8 @@ public function set($key = null, $value = null); function getSession() { $employ = EpiSession::employ(); - $class = array_shift($employ); + if($employ !== null) + $class = array_shift($employ); if($employ && class_exists($class)) return EpiSession::getInstance($class, $employ); elseif(class_exists(EpiSession::PHP)) diff --git a/src/EpiSession_Apc.php b/src/EpiSession_Apc.php index 65e10ea..11b5b56 100644 --- a/src/EpiSession_Apc.php +++ b/src/EpiSession_Apc.php @@ -39,7 +39,11 @@ public function __construct($params = null) $key = array_shift($params); if(empty($key) && empty($_COOKIE[EpiSession::COOKIE])) - setcookie(EpiSession::COOKIE, md5(uniqid(rand(), true)), time()+1209600, '/'); + { + $uid = md5(uniqid(rand(), true)); + setcookie(EpiSession::COOKIE, $uid, time()+1209600, '/'); + $_COOKIE[EpiSession::COOKIE] = $uid; + } $this->key = empty($key) ? $_COOKIE[EpiSession::COOKIE] : $key; $this->store = $this->getAll();