本文整理汇总了PHP中SessionController::addCode方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionController::addCode方法的具体用法?PHP SessionController::addCode怎么用?PHP SessionController::addCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionController
的用法示例。
在下文中一共展示了SessionController::addCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: time
// put cellphone number into session, in case user use an different number to register.
$sessionController->addCellphone($phone);
}
$last_time = $sessionController->getVerifyTime();
if (!empty($last_time)) {
$this_time = time();
$interval = $this_time - $last_time;
if ($interval < 120) {
echo "时间间隔太短!";
return;
}
}
$user = $userDao->getByPhone($phone);
if ($user) {
echo "手机号已被注册";
return;
}
// Generate a 6-digits random number
$random = rand(100000, 999999);
// Send to user's cellphone
$sms = new SmsSender();
if ($sms->sendVerifyCode($phone, $random)) {
echo "{\"msg\":\"success\"}";
// put it in the session
$sessionController->addCode($random);
$sessionController->addVerifyTime(time());
} else {
echo "\n短信服务失败!";
}
// temporary return to page
// echo $random;
示例2: header
if ($today_time == WechatLotteryService::OVER_LIMIT) {
// Draw action over daily limit
header("Location:result.php?price=-1&casa=" . $r . "&gua=" . $gua);
} else {
if ($reward_row) {
// Already won, 中过奖了
header("Location:result.php?price=0&casa=" . $r . "&gua=" . $gua);
} else {
$win = $wls->draw();
// 中奖了
if ($win) {
// 中了几等奖
$price_level = $wls->draw_price();
// save in session
$sc = new SessionController();
$sc->addCode($openid);
// save in database
$wls->save_winner($openid, $price_level);
// redirect
header("Location:result.php?price=" . $price_level . "&casa=" . $r . "&gua=" . $gua);
} else {
header("Location:result.php?price=0&casa=" . $r . "&gua=" . $gua);
}
}
}
} else {
echo "微信信息获取失败!";
}
/*//根据openid和access_token查询用户信息
$get_user_info_url = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$access_token
.'&openid='.$openid.'&lang=zh_CN';