本文整理匯總了PHP中SessionHandler::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP SessionHandler::set方法的具體用法?PHP SessionHandler::set怎麽用?PHP SessionHandler::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SessionHandler
的用法示例。
在下文中一共展示了SessionHandler::set方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save
public function save()
{
if (count($this->messages) > 0) {
$this->flash = array_merge($this->flash, $this->messages);
$this->clear();
}
SessionHandler::set('PIMPLE_FLASH', $this->flash);
}
示例2: captcha
/**
* Renders a captcha
* @See FormTagLib::tagCaptcha
*/
public function captcha()
{
$width = Request::get('w', 210);
$height = Request::get('h', 40);
$characters = Request::get('c', 6);
$font = Pimple::instance()->getRessource('monofont.ttf');
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1);
$i++;
}
/* font size will be 75% of the image height */
$font_size = $height * 0.75;
$image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
/* generate random dots in background */
for ($i = 0; $i < $width * $height / 3; $i++) {
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
}
/* generate random lines in background */
for ($i = 0; $i < $width * $height / 150; $i++) {
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
}
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4]) / 2;
$y = ($height - $textbox[5]) / 2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $font, $code) or die('Error in imagettftext function');
/* output captcha image to browser */
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
SessionHandler::set('CAPTCHA', $code);
Pimple::end();
}
示例3: clear
public function clear($id)
{
$id = get_class($this) . '_' . $id;
SessionHandler::set($id, null);
}