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

Yaf_Session::current

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Get current session entry value

Description

Yaf_Session::current(): mixed

Returns the value of the current session entry during iteration.

Parameters Parameters

Return Values

The value of the current session entry.

Examples

Yaf_Session::current example

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

$session->set("user_id", 42);
$session->set("is_vip", true);

foreach ($session as $key => $value) {
    // Yaf_Session::current() yields each value while iterating
    echo "$key => ";
    var_dump($value);
}
?>

The above example will output something similar to:

output
user_id => int(42)
is_vip => bool(true)

See Also

  • Yaf_Session::key
  • Yaf_Session::next
  • Yaf_Session::rewind
  • Yaf_Session::valid

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