本文整理汇总了PHP中fSession::add方法的典型用法代码示例。如果您正苦于以下问题:PHP fSession::add方法的具体用法?PHP fSession::add怎么用?PHP fSession::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fSession
的用法示例。
在下文中一共展示了fSession::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddToNonArray
public function testAddToNonArray()
{
$this->setExpectedException('fProgrammerException');
fSession::open();
fSession::set('non_array', 'value');
fSession::add('non_array', 'value2');
}
示例2: generateCSRFToken
/**
* 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;
}