CHttpSessionIterator

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

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

Public Methods

Method Description Defined 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#35 (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#64 (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#54 (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#73 (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#44 (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#87 (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.

© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc/api/1.1/CHttpSessionIterator