You are here

public function AutologoutTestSessionCleanupOnLogin::stashSession in Automated Logout 7.4

Initialise a new unique session.

Return value

string Unique identifier for the session just stored. It is the cookiefile name.

2 calls to AutologoutTestSessionCleanupOnLogin::stashSession()
AutologoutTestSessionCleanupOnLogin::restoreSession in tests/autologout.test
Restore a previously stashed session.
AutologoutTestSessionCleanupOnLogin::testSessionCleanupAtLogin in tests/autologout.test
Test that stale sessions are cleaned up at login.

File

tests/autologout.test, line 113
Simpletest tests for autologout.

Class

AutologoutTestSessionCleanupOnLogin
Test session cleanup on login.

Code

public function stashSession() {
  if (empty($this->cookieFile)) {

    // No session to stash.
    return;
  }

  // The session_id is the current cookieFile.
  $session_id = $this->cookieFile;
  $this->curlHandles[$session_id] = $this->curlHandle;
  $this->loggedInUsers[$session_id] = $this->loggedInUser;

  // Reset Curl.
  unset($this->curlHandle);
  $this->loggedInUser = FALSE;

  // Set a new unique cookie filename.
  do {
    $this->cookieFile = $this->public_files_directory . '/' . $this
      ->randomName() . '.jar';
  } while (isset($this->curlHandles[$this->cookieFile]));
  return $session_id;
}