mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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
This commit is contained in:
parent
eb202d44f9
commit
8cfaa0538b
1 changed files with 97 additions and 0 deletions
97
cake/libs/view/helpers/session.php
Normal file
97
cake/libs/view/helpers/session.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue