From 483fa2772d1201f9a28cf88ff42cb3746445551e Mon Sep 17 00:00:00 2001 From: Kenneth Gustine Date: Sat, 10 Jan 2015 01:39:01 -0600 Subject: [PATCH 1/2] use a session manager without calling employ() Warning: array_shift() expects parameter 1 to be array, null given in EpiSession.php on line 58 If you initialize one, and only one, of the session implementations, you should not have to call employ(). Epi::init('session-apc'); getSession()->set('this','that'); that code would generate a warning because employ is called without an argument so it returns null. array_shift() is then called on $employ which causes the warning. I think this could be cleaned up more, but this is a quick fix. --- src/EpiSession.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)) From 064cb4de54fdaf1b7b5d34fdfdc9f0ff80c94793 Mon Sep 17 00:00:00 2001 From: Kenneth Gustine Date: Sat, 10 Jan 2015 02:08:29 -0600 Subject: [PATCH 2/2] APC Session Key on Initial Creation Notice: Undefined index: EpiSession in EpiSession_Apc.php on line 48 $_COOKIE[EpiSession::COOKIE] is not available after setcookie() is called. It will only be available after the next page refresh. Therefore we need to set it manually to make it immediately available. --- src/EpiSession_Apc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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();