From 8cfaa0538b97fed84ad8f778d5b47e28532bdc61 Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 7 Sep 2006 20:35:35 +0000 Subject: [PATCH] Adding SessionHelper to 1.2 branch git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3455 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/session.php | 97 ++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 cake/libs/view/helpers/session.php diff --git a/cake/libs/view/helpers/session.php b/cake/libs/view/helpers/session.php new file mode 100644 index 000000000..d4b1e1e60 --- /dev/null +++ b/cake/libs/view/helpers/session.php @@ -0,0 +1,97 @@ + + * Copyright (c) 2006, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright (c) 2006, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP v 1.1.7.3328 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ + +/** + * Short description for file. + * + * Long description for file + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + * + */ +class SessionHelper extends Helper{ + var $__Session; + var $__active = true; + +/** + * Enter description here... + * + */ + function __construct($base = null) { + if (!defined('AUTO_SESSION') || AUTO_SESSION == true) { + $this->__Session =& new CakeSession($base); + } else { + $this->__active = false; + } + parent::__construct(); + } + + function read($name = null) { + if ($this->__active === true) { + return $this->__Session->readSessionVar($name); + } + return false; + } + + function check($name) { + if ($this->__active === true) { + return $this->__Session->checkSessionVar($name); + } + return false; + } + + function error() { + if ($this->__active === true) { + return $this->__Session->getLastError(); + } + return false; + } + + function flash($key = 'flash') { + if ($this->__active === true) { + if ($this->__Session->checkSessionVar('Message.' . $key)) { + e($this->__Session->readSessionVar('Message.' . $key)); + $this->__Session->delSessionVar('Message.' . $key); + } else { + return false; + } + } + return false; + } + + function valid() { + if ($this->__active === true) { + return $this->__Session->isValid(); + } + } +} + +?> \ No newline at end of file