Add component and helper wrapper methods.

This commit is contained in:
euromark 2014-12-23 03:50:35 +01:00
parent 813925abee
commit 545ff20e1d
2 changed files with 30 additions and 6 deletions

View file

@ -41,7 +41,7 @@ class SessionComponent extends Component {
} }
/** /**
* Used to write a value to a session key. * Writes a value to a session key.
* *
* In your controller: $this->Session->write('Controller.sessKey', 'session value'); * In your controller: $this->Session->write('Controller.sessKey', 'session value');
* *
@ -56,7 +56,7 @@ class SessionComponent extends Component {
} }
/** /**
* Used to read a session values for a key or return values for all keys. * Reads a session value for a key or returns values for all keys.
* *
* In your controller: $this->Session->read('Controller.sessKey'); * In your controller: $this->Session->read('Controller.sessKey');
* Calling the method without a param will return all session vars * Calling the method without a param will return all session vars
@ -70,7 +70,7 @@ class SessionComponent extends Component {
} }
/** /**
* Wrapper for SessionComponent::del(); * Deletes a session value for a key.
* *
* In your controller: $this->Session->delete('Controller.sessKey'); * In your controller: $this->Session->delete('Controller.sessKey');
* *
@ -83,7 +83,19 @@ class SessionComponent extends Component {
} }
/** /**
* Used to check if a session variable is set * Reads and deletes a session value for a key.
*
* In your controller: `$this->Session->consume('Controller.sessKey');`
*
* @param string $name the name of the session key you want to read
* @return mixed values from the session vars
*/
public function consume($name) {
return CakeSession::consume($name);
}
/**
* Checks if a session variable is set.
* *
* In your controller: $this->Session->check('Controller.sessKey'); * In your controller: $this->Session->check('Controller.sessKey');
* *

View file

@ -30,7 +30,7 @@ App::uses('CakeSession', 'Model/Datasource');
class SessionHelper extends AppHelper { class SessionHelper extends AppHelper {
/** /**
* Used to read a session values set in a controller for a key or return values for all keys. * Reads a session value for a key or returns values for all keys.
* *
* In your view: `$this->Session->read('Controller.sessKey');` * In your view: `$this->Session->read('Controller.sessKey');`
* Calling the method without a param will return all session vars * Calling the method without a param will return all session vars
@ -44,7 +44,19 @@ class SessionHelper extends AppHelper {
} }
/** /**
* Used to check is a session key has been set * Reads and deletes a session value for a key.
*
* In your view: `$this->Session->consume('Controller.sessKey');`
*
* @param string $name the name of the session key you want to read
* @return mixed values from the session vars
*/
public function consume($name) {
return CakeSession::consume($name);
}
/**
* Checks if a session key has been set.
* *
* In your view: `$this->Session->check('Controller.sessKey');` * In your view: `$this->Session->check('Controller.sessKey');`
* *