PHP 8.6.0 Beta 3 is available for testing

Yaf_Session::rewind

(Yaf >=1.0.0)

Yaf_Session::rewindReset session iterator to first entry

Description

public function Yaf_Session::rewind(): void

Rewinds the internal iterator to the first session entry.

Parameters

This function has no parameters.

Return Values

No value is returned.

Examples

Example #1 Yaf_Session::rewind() example

<?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:

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

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top