AppserverIo\Appserver\ServletEngine\Session\FilesystemSessionHandler::save PHP Method

save() public method

Saves the passed session to the persistence layer.
public save ( AppserverIo\Psr\Servlet\ServletSessionInterface $session ) : void
$session AppserverIo\Psr\Servlet\ServletSessionInterface The session to save
return void
    public function save(ServletSessionInterface $session)
    {
        // don't save the session if it has been destroyed
        if ($session->getId() == null) {
            return;
        }
        // prepare the session filename
        $sessionFilename = $this->getSessionSavePath($this->getSessionSettings()->getSessionFilePrefix() . $session->getId());
        // update the checksum and the file that stores the session data
        if (file_put_contents($sessionFilename, $this->marshall($session)) === false) {
            throw new SessionCanNotBeSavedException(sprintf('Session with ID %s can\'t be saved'));
        }
    }