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

Yaf_Session::valid

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Check if current session position is valid

Description

Yaf_Session::valid(): bool

Checks whether the current session iterator position is valid.

Parameters Parameters

Return Values

Returns true if the current position is valid, false otherwise.

Examples

Yaf_Session::valid example

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

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

$session->rewind();
var_dump($session->valid());

$session->next();
// past the last entry, the position is no longer valid
var_dump($session->valid());
?>

The above example will output something similar to:

output
bool(true)
bool(false)

See Also

  • Yaf_Session::current
  • Yaf_Session::key
  • Yaf_Session::next
  • Yaf_Session::rewind

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