php8.5
Home/ Manual/ yaf / yaf_session/ Yaf_Session::rewind

Yaf_Session::rewind

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Reset session iterator to first entry

Description

Yaf_Session::rewind(): void

Rewinds the internal iterator to the first session entry.

Parameters Parameters

Return Values

No value is returned.

Examples

Yaf_Session::rewind example

php
<?php
$session = Yaf_Session::getInstance();
$session->start();

$session->set("user_id", 42);
$session->set("lang", "en");

foreach ($session as $key => $value) {
    echo "$key => $value", PHP_EOL;
}

// a new foreach implicitly calls rewind() again
foreach ($session as $key => $value) {
    echo "$key => $value", PHP_EOL;
}
?>

The above example will output something similar to:

output
user_id => 42
lang => en
user_id => 42
lang => en

See Also

  • Yaf_Session::current
  • Yaf_Session::key
  • Yaf_Session::next
  • Yaf_Session::valid

Source: reference/yaf/yaf_session/rewind.xml · from the official PHP manual (php/doc-en)