// Switch browser cookie to anonymous user, then back to user 1.
$session_cookie_name =
$this->
getSessionName();
$session_cookie_value =
$session->
getCookie($session_cookie_name);
$session->
restart();
$this->
initFrontPage();
// Session restart always resets all the cookies by design, so we need to
// add the old session cookie again.
$session->
setCookie($session_cookie_name,
$session_cookie_value);
// Verify that the session data persists through browser close.
$this->
drupalGet('session-test/get'
);
$this->
assertSession()->
pageTextContains($value_1);
$this->mink->
setDefaultSessionName('default'
);
// Logout the user and make sure the stored value no longer persists.
$this->
drupalLogout();
$this->
sessionReset();
// Verify that after logout, previous user's session data is not available.
$this->
drupalGet('session-test/get'
);
$this->
assertSession()->
pageTextNotContains($value_1);
// Now try to store some data as an anonymous user.
$value_3 =
$this->
randomMachineName();
// Verify that session data is stored for anonymous user.