本文整理汇总了PHP中Session_start函数的典型用法代码示例。如果您正苦于以下问题:PHP Session_start函数的具体用法?PHP Session_start怎么用?PHP Session_start使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Session_start函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
Session_start();
$builder = new CaptchaBuilder();
$builder->build();
$phrase = $builder->getPhrase();
$_SESSION['phrase'] = $phrase;
return View::make('login')->with(array('captcha' => $builder, 'links' => $this->link()));
}
示例2: init
public static function init()
{
// check for current session
if (!self::get('session')) {
//create session if non-existent, suppress errors.
@Session_start();
// set flag that session was created
self::set('session', TRUE);
}
}
示例3: initialize
public function initialize()
{
$CI =& get_instance();
$num = "";
for ($i = 0; $i < 4; $i++) {
$num .= rand(0, 9);
}
Session_start();
$_SESSION["Checknum"] = $num;
$CI->load->library('session');
$CI->session->set_userdata('Checknum', $num);
echo $CI->session->userdata('Checknum');
echo $_SESSION["Checknum"];
}
示例4: Session_start
<?php
Session_start();
if (!isset($_SESSION['tipo'])) {
echo "<script language=\"javascript\">\n\t\t\t\t\talert(\"Inicie sesion primero\");\n\t\t\t\t\twindow.location.href = \"../index.php\"\n\t\t\t\t</script>";
} elseif ($_SESSION['tipo'] != 'd') {
echo "<script language=\"javascript\">\n\t\t\t\t\talert(\"No tiene permisos!\");\n\t\t\t\t\twindow.location.href = \"../index.php\"\n\t\t\t\t</script>";
}
示例5: resendCheckCode
public function resendCheckCode()
{
Session_start();
$email = Input::get('email');
//产生随机验证码发到邮箱
$possible_charactors = "abcdefghijklmnopqrstuvwxyz0123456789";
$salt = "";
//验证码
while (strlen($salt) < 6) {
$salt .= substr($possible_charactors, rand(0, strlen($possible_charactors) - 1), 1);
}
//发送邮件
Mail::send('emails/token', array('token' => $salt), function ($message) use($email) {
$message->to($email, '')->subject('中国儿童戏剧教育网验证码!');
});
$_SESSION['registerSalt'] = $salt;
return Response::json(array('errCode' => 0, 'message' => '验证码发送成功!'));
}
示例6: pwdReset
public function pwdReset()
{
Session_start();
$email = Input::get('email');
$check_code = Input::get('check_code');
$password = Input::get('password');
// $re_password = Input::get('re_password');
if ($email != Session::get('reset_email')) {
return Response::json(array('errCode' => 1, 'message' => '邮箱不正确!'));
}
if ($check_code != Session::get('reset_code')) {
return Response::json(array('errCode' => 2, 'message' => '验证码不正确!'));
}
if (strlen($password) < 6 || strlen($password) > 20) {
return Response::json(array('errCode' => 3, 'message' => '密码长度为6到20之间!'));
}
// if($password != $re_password)
// return Response::json(array('errCode'=>4, 'messsage' =>'两次输入的密码不一致!'));
try {
$user = Sentry::findUserByLogin($email);
if ($user->checkResetPasswordCode($check_code)) {
if ($user->attemptResetPassword($check_code, $password)) {
return Response::json(array('errCode' => 0, 'message' => '密码修改成功!'));
} else {
return Response::json(array('errCode' => 5, 'message' => '密码修改失败!'));
}
} else {
return Response::json(array('errCode' => 6, 'message' => '密码无效!'));
}
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return Response::json(array('errCode' => 7, 'message' => '用户不存在!'));
}
// $user = User::where('email', '=', $email)->first();
// $user->password = Hash::make($password);
// if(!$user->save())
// return Response::json(array('errCode'=>5, 'message'=>'密码修改失败!'));
// return Response::json(array('errCode'=>0, 'message'=>'密码修改成功!'));
}
示例7: bSiteRegister
public function bSiteRegister()
{
Session_start();
// $captcha = Input::get('captcha');
// if( $captcha != $_SESSION['phrase'])
// return Response::json(array('errCode'=>8, 'message'=> '验证码不正确'));
$data = array('login_account' => Input::get('login_account'), 'password' => Input::get('password'), 're_password' => Input::get('re_password'));
$rules = array('login_account' => 'required|email|unique:users,login_account', 'password' => 'required|alpha_num|between:6,16', 're_password' => 'required|same:password');
$messages = array('login_account.required' => 1, 'password.required' => 1, 're_password.required' => 1, 'login_account.unique' => 2, 'login_account.email' => 3, 'password.alpha_num' => 4, 'password.between' => 5, 're_password.same' => 6);
$validation = Validator::make($data, $rules, $messages);
if ($validation->fails()) {
//获得错误信息数组
$number = $validation->messages()->all();
switch ($number[0]) {
case 1:
return Response::json(array('errCode' => 1, 'message' => '信息填写不完整!'));
case 2:
return Response::json(array('errCode' => 2, 'message' => '邮箱已被注册!'));
case 3:
return Response::json(array('errCode' => 3, 'message' => '邮箱格式不正确!'));
case 4:
return Response::json(array('errCode' => 4, 'message' => '密码只能包含字母和数字!'));
case 5:
return Response::json(array('errCode' => 5, 'message' => '密码必须是6到20位之间!'));
case 6:
return Response::json(array('errCode' => 6, 'message' => '两次密码输入不一致!'));
default:
return Response::json(array());
}
} else {
$token = md5($data['login_account'] . time());
//发送邮件
Mail::send('emails/token', array('token' => $token), function ($message) use($data) {
$message->to($data['login_account'], '')->subject('车尚提醒您:请验证您的邮箱');
});
try {
$user = Sentry::createUser(array('login_account' => $data['login_account'], 'password' => $data['password'], 'user_type' => 1, 'status' => 10));
} catch (Cartalyst\Sentry\Users\UserExistsException $e) {
return Response::json(array('errCode' => 7, 'message' => '该用户已存在'));
}
//储存数据
$user = User::where('login_account', $user->login_account)->first();
Sentry::login($user, false);
Cache::put($token, $user, 1440);
// var_dump($user->user_id);
return Response::json(array('errCode' => 0, 'message' => '验证码发送成功!'));
}
}