public function write() { $value = HTTP::jsonEncode($this->_data ? $this->_data : $this->_contents); $label = $this->_source; $path = $this->config('location'); $expire = (int) $this->config('expire'); $cookiesecure = $this->config('secure'); $path = $path ? $path : HTTP::domain(); $cookiedie = DevNumber::isValid($expire) ? time() + (int) $expire : (int) $expire; //expire in one hour $cookiesecure = (bool) $secure; $status = HTTP::cookie($label, $value, $cookiedie, $path = null, $cookiesecure) ? self::STATUS_SUCCESS : self::STATUS_FAILED; $this->status($status); }
static function session($var, $value = null, $expire = null, $path = null, $secure = false) { if (DevValue::isNull($value)) { return isset($_SESSION[$var]) ? $_SESSION[$var] : null; } if (session_id() == '') { $domain = $path ? substr($path, 0, strpos($path, '/')) : HTTP::domain(); $dir = $path ? substr($path, strpos($path, '/'), strlen($path)) : '/'; $cookiedie = DevNumber::isValid($expire) ? time() + (int) $expire : (int) $expire; //expire in one hour $cookiesecure = (bool) $secure; session_set_cookie_params($cookiedie, $dir, $domain, $cookiesecure); session_start(); } $status = ($_SESSION[$var] = $value) ? true : false; return $status; }
public function testValueReturnsAsNumeric() { $object = new DevNumber('letters'); $this->assertTrue(is_numeric($object->value())); }