session_unset logs out user when viewing the page
I was able to combine two of the responses to solve my problem.  I indeed updated it to use the symfony that is now part of drupal 8.  (Comment #3).  Reading https://www.drupal.org/docs/7/security/safely-impersonating-another-user gave me an idea to test for anonymity.  So I ended up changing the original code to:

if(\Drupal::currentUser()-&gt;isAnonymous()) {
    $request = \Drupal::request();
    $session = $request-&gt;getSession();
    $session-&gt;clear();
    if($session-&gt;getId() == '') {
        ini_set('session.gc_maxlifetime','28800');
        $session-&gt;start();
    }
}


This seemed to make my problem go away.  Not sure if this is the best solution, or a band-aid, but it worked for me.