Is it possible to unset private_tempstore values? I have a block that creates a private_tempstore value (which I understand works exactly like PHP sessions).

How do I unset that value.

This is the code I am using for the block.

class SsoSessionBlock extends BlockBase {
    /**
     * {@inheritdoc}
     */
    public function build(){
        $value = 'dav';
        $session = \Drupal::service('user.private_tempstore')-&gt;get('achva_sso');
        $session-&gt;set('name', $value);


        return [
            '#type' =&gt; 'markup',
            '#markup' =&gt; $this-&gt;t('The output of super SsoSessionBlock block.'),
        ];
    }
}


I saw this method, but I am not sure how I am supposed to use it.

I tried the following code, but I get an error.

namespace Drupal\achva_sso\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\user;


class SsoController extends ControllerBase{
    public function ssoLogout(){

        $session = \Drupal::service('user.private_tempstore')-&gt;get('achva_sso');
        PrivateTempStore::delete('name');

        if(isset($session)){
            $status = $session .' is logged in';
        }else{
            $status = 'is logged out';
        }
        return[
            '#type' =&gt; 'markup',
            '#markup' =&gt; '&lt;p&gt;' . $status . '&lt;/p&gt;' ,
        ];



    }
}


How do I unset a value I previously set?
delete() is the method to delete a value in the store.
$session = \Drupal::service('user.private_tempstore')-&gt;get('achva_sso');
$session-&gt;delete('name');

'name' is the value passed as first argument in any call to set().
You don't use PrivateTempStore::delete() since it's not a static method and it would throw errors or warnings, if called as static method.
As side note, user.private_tempstore is a deprecated service. Instead, the tempstore.private service should be used. (See User module's user.private_tempstore and user.shared_tempstore services moved to core for more details.) In the latest Drupal 8.5.x version, the service is marked as deprecated directly in the user.services.yml file.
class: Drupal\user\PrivateTempStoreFactory
arguments:
  - '@keyvalue.expirable'
  - '@lock'
  - '@current_user'
  - '@request_stack'
  - '%tempstore.expire%'
deprecated: 'The &quot;%service_id%&quot; service is deprecated. You should use the ''tempstore.private'' service instead. See https://www.drupal.org/node/2935639.'
tags:
  - { name: backend_overridable }

It should also be better to use dependency injection: A class extending BlockBase, or ControllerBase, can implement the create() method to load new dependencies.