示例#1
0
 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);
 }
示例#2
0
 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;
 }
示例#3
0
 public function testValueReturnsAsNumeric()
 {
     $object = new DevNumber('letters');
     $this->assertTrue(is_numeric($object->value()));
 }