0 follower

CHttpSessionIterator

Package system.web
Inheritance class CHttpSessionIterator
Implements Iterator, Traversable
Since 1.0
Version $Id$
Source Code framework/web/CHttpSessionIterator.php
CHttpSessionIterator implements an interator for CHttpSession.

It allows CHttpSession to return a new iterator for traversing the session variables.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. CHttpSessionIterator
current() Returns the current array element. CHttpSessionIterator
key() Returns the key of the current array element. CHttpSessionIterator
next() Moves the internal pointer to the next array element. CHttpSessionIterator
rewind() Rewinds internal array pointer. CHttpSessionIterator
valid() Returns whether there is an element at current position. CHttpSessionIterator

Method Details

__construct() method
public void __construct()
Source Code: framework/web/CHttpSessionIterator.php#36 (show)
public function __construct()
{
    
$this->_keys=array_keys($_SESSION);
}

Constructor.

current() method
public mixed current()
{return} mixed the current array element
Source Code: framework/web/CHttpSessionIterator.php#65 (show)
public function current()
{
    return isset(
$_SESSION[$this->_key])?$_SESSION[$this->_key]:null;
}

Returns the current array element. This method is required by the interface Iterator.

key() method
public mixed key()
{return} mixed the key of the current array element
Source Code: framework/web/CHttpSessionIterator.php#55 (show)
public function key()
{
    return 
$this->_key;
}

Returns the key of the current array element. This method is required by the interface Iterator.

next() method
public void next()
Source Code: framework/web/CHttpSessionIterator.php#74 (show)
public function next()
{
    do
    {
        
$this->_key=next($this->_keys);
    }
    while(!isset(
$_SESSION[$this->_key]) && $this->_key!==false);
}

Moves the internal pointer to the next array element. This method is required by the interface Iterator.

rewind() method
public void rewind()
Source Code: framework/web/CHttpSessionIterator.php#45 (show)
public function rewind()
{
    
$this->_key=reset($this->_keys);
}

Rewinds internal array pointer. This method is required by the interface Iterator.

valid() method
public boolean valid()
{return} boolean
Source Code: framework/web/CHttpSessionIterator.php#88 (show)
public function valid()
{
    return 
$this->_key!==false;
}

Returns whether there is an element at current position. This method is required by the interface Iterator.