Uploader

An all around general purpose file uploader for CakePHP. Packaged as a stand alone plugin with file validation, file scanning and support for a wide range of basic mime types.

Refresh Auth

Refreshes the Auth session with new/updated data. Can be placed within your AppController.

Function: _refreshAuth()
Category: CakePHP
Views: 2,221
Permalink - Tinylink

/**
 * Refreshes the Auth session with new/updated data
 * @param string $field
 * @param string $value
 * @return void 
 */
function _refreshAuth($field = '', $value = '') {
	if (!empty($field) && !empty($value)) { 
		$this->Session->write($this->Auth->sessionKey .'.'. $field, $value);
	} else {
		if (isset($this->User)) {
			$this->Auth->login($this->User->read(false, $this->Auth->user('id')));
		} else {
			$this->Auth->login(ClassRegistry::init('User')->findById($this->Auth->user('id')));
		}
	}
}

Return to Snippets