The problem is that the value of the test variable is not displayed the first time. In theory, it should be so. If the condition if(!$test)
register if(!$session->get('test'))
, then everything is OK, but it is not suitable.
How to make my method display everything from the first time, and not from the second?
$test = $session->get('test'); if(!$test) { $session->add('test', 'asdasd'); } echo $test;