Neos\Flow\Session\TransientSession::putData PHP Method

putData() public method

Stores the given data under the given key in the session
public putData ( string $key, object $data ) : void
$key string The key under which the data should be stored
$data object The data to be stored
return void
    public function putData($key, $data)
    {
        if ($this->started !== true) {
            throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034661);
        }
        $this->data[$key] = $data;
    }

Usage Example

 /**
  * @test
  */
 public function hasKeyReturnsTrueOrFalseAccordingToAvailableKeys()
 {
     $session = new Session\TransientSession();
     $session->start();
     $session->putData('theKey', 'some data');
     $this->assertTrue($session->hasKey('theKey'));
     $this->assertFalse($session->hasKey('noKey'));
 }