You are here

public function SessionLimitBaseTestCase::stashSession in Session Limit 7.2

Same name and namespace in other branches
  1. 8 tests/session_limit.test \SessionLimitBaseTestCase::stashSession()
  2. 6.2 tests/session_limit.test \SessionLimitBaseTestCase::stashSession()
  3. 2.x tests/session_limit.test \SessionLimitBaseTestCase::stashSession()

Initialise a new unique session.

Return value

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

4 calls to SessionLimitBaseTestCase::stashSession()
SessionLimitBaseTestCase::assertSessionLogout in tests/session_limit.test
Test that an individual user can have up to a specifed number of sessions.
SessionLimitBaseTestCase::assertSessionPrevent in tests/session_limit.test
Test that new sessions cannot be created past a maximum.
SessionLimitBaseTestCase::restoreSession in tests/session_limit.test
Restore a previously stashed session.
SessionLimitSessionTestCase::testSessionStashAndRestore in tests/session_limit.test
Test session stash and restore.

File

tests/session_limit.test, line 194
Simpletest tests for session_limit.

Class

SessionLimitBaseTestCase
Base test for session limits.

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;
}