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

Yaf_Session::key

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Get current session entry key

Description

Yaf_Session::key(): mixed

Returns the key of the current session entry during iteration.

Parameters Parameters

Return Values

The key of the current session entry.

Examples

Yaf_Session::key example

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

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

for ($session->rewind(); $session->valid(); $session->next()) {
    echo $session->key(), " => ", var_export($session->current(), true), PHP_EOL;
}
?>

The above example will output something similar to:

output
user_id => 42
lang => 'en'

See Also

  • Yaf_Session::current
  • Yaf_Session::next
  • Yaf_Session::rewind
  • Yaf_Session::valid

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