public function testAddToNonArray() { $this->setExpectedException('fProgrammerException'); fSession::open(); fSession::set('non_array', 'value'); fSession::add('non_array', 'value2'); }
/** * Returns a request token that should be placed in each HTML form to prevent [http://en.wikipedia.org/wiki/Cross-site_request_forgery cross-site request forgery] * * This method will return a random 15 character string that should be * placed in a hidden `input` element on every HTML form. When the form * contents are being processed, the token should be retrieved and passed * into ::validateCSRFToken(). * * The value returned by this method is stored in the session and then * checked by the validate method, which helps prevent cross site request * forgeries and (naive) automated form submissions. * * Tokens generated by this method are single use, so a user must request * the page that generates the token at least once per submission. * * @param string $url The URL to generate a token for, default to the current page * @return string The token to be submitted with the form */ public static function generateCSRFToken($url = NULL) { if ($url === NULL) { $url = fURL::get(); } $token = fCryptography::randomString(16); fSession::add(__CLASS__ . '::' . $url . '::csrf_tokens', $token); return $token; }