本文整理汇总了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);
}