function write($var)
 {
     // write variable
     YDPersistent::set('xpto', $var);
     // add result string to span
     $this->ajax->addResult('spanresult', 'Variable stored');
     // clean text box
     $this->ajax->addResult('variable', '');
     // return response to client browser
     return $this->ajax->processResults();
 }
 function actionDefault()
 {
     // Create the object
     $obj = new MySampleClass();
     // Set the persistent data
     YDPersistent::set('simple_string_encrypted', 'Pieter Claerhout', 'test');
     YDPersistent::set('my_obj_encypted', $obj, 'test');
     YDPersistent::set('simple_string', 'Pieter Claerhout');
     YDPersistent::set('my_obj', $obj);
     YDPersistent::set('example', 'test');
     YDPersistent::delete('example');
     // Redirect to the check action
     $this->redirectToAction('check', array('simple_string' => 'overriden value'));
 }
 /**
  *  This function returns a variable from the configuration. If the configuration variable doesn't exist or it's
  *  a wrong password, it returns the default value if this value isn't null, otherwise returns a fatal error.
  *
  *	@param	$name       The name of the configuration variable to retrieve.
  *  @param  $default    (optional) If not null, this value will be returned if the configuration setting doesn't
  *                      exist in the configuration.
  *  @param  $passwd     (optional) If not null, the data will be decrypted with this password.
  *
  *	@returns	The value of the configuration variable.
  */
 function get($name, $default = null, $passwd = null)
 {
     // Initialize the store
     YDPersistent::_init();
     // If the $_GET variable exists, return that one
     if (YDConfig::get('YD_ALLOW_OVERRIDE_QS', false) === true) {
         if (isset($_GET[$name]) === true) {
             YDPersistent::set($name, $_GET[$name], $passwd);
         }
     }
     // Check if the key exists
     if (!YDPersistent::exists($name)) {
         // Check if we have a default, if not, raise an error
         if (!is_null($default)) {
             return $default;
         } else {
             trigger_error('Persistent variable "' . $name . '" is not defined.', YD_ERROR);
         }
     }
     // Get the value
     $obj = $_COOKIE[YDConfig::get('YD_PERSISTENT_STORE_NAME')][$name];
     // Decrypt the data if needed
     if (is_null($passwd) && !is_null(YDConfig::get('YD_PERSISTENT_DEFAULT_PASSWORD', null))) {
         $passwd = YDConfig::get('YD_PERSISTENT_DEFAULT_PASSWORD', null);
     }
     if (!is_null($passwd)) {
         $obj = YDEncryption::decrypt($passwd, $obj);
     }
     // Now, we need to base64 decode and unserialize
     $obj = @unserialize(base64_decode($obj));
     // Return the default if decryption failed
     if (!$obj && !is_null($default)) {
         return $default;
     }
     // Return the object
     return $obj;
 }
 /**
  *  This function sets a persistent field value.
  *
  *  @param  $name  Field name
  *  @param  $value Field value
  */
 function setField($name, $value)
 {
     $values = YDPersistent::get('YD_INSTALLER_VALUES', array(), 'YD_INSTALLER');
     $values[$name] = $value;
     $this->{$name} = $value;
     YDPersistent::set('YD_INSTALLER_VALUES', $values, 'YD_INSTALLER', null, true);
 }