setLastAccessTime example


  public function testWhosOnlineBlock() {
    $request_time = \Drupal::time()->getRequestTime();
    // Generate users.     $user1 = User::create([
      'name' => 'user1',
      'mail' => 'user1@example.com',
    ]);
    $user1->addRole('administrator');
    $user1->activate();
    $user1->setLastAccessTime($request_time);
    $user1->save();

    $user2 = User::create([
      'name' => 'user2',
      'mail' => 'user2@example.com',
    ]);
    $user2->activate();
    $user2->setLastAccessTime($request_time + 1);
    $user2->save();

    $user3 = User::create([
      
Home | Imprint | This part of the site doesn't use cookies.