当前位置: 首页>>代码示例>>PHP>>正文


PHP session函数代码示例

本文整理汇总了PHP中session函数的典型用法代码示例。如果您正苦于以下问题:PHP session函数的具体用法?PHP session怎么用?PHP session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了session函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: slots

 public function slots()
 {
     $user = Auth::user();
     $location = $user->location;
     $slot = Slot::where('location', '=', $location)->first();
     $input = Input::get('wager');
     $owner = User::where('name', '=', $slot->owner)->first();
     $num1 = rand(1, 10);
     $num2 = rand(5, 7);
     $num3 = rand(5, 7);
     if ($user->name != $owner->name) {
         if ($num1 & $num2 & $num3 == 6) {
             $money = rand(250, 300);
             $payment = $money += $input * 1.75;
             $user->money += $payment;
             $user->save();
             session()->flash('flash_message', 'You rolled three sixes!!');
             return redirect('/home');
         } else {
             $user->money -= $input;
             $user->save();
             $owner->money += $input;
             $owner->save();
             session()->flash('flash_message_important', 'You failed to roll three sixes!!');
             return redirect(action('SlotsController@show', [$slot->location]));
         }
     } else {
         session()->flash('flash_message_important', 'You own this slot!!');
         return redirect(action('SlotsController@show', [$slot->location]));
     }
 }
开发者ID:mathewsandi,项目名称:MafiaGame,代码行数:31,代码来源:SlotsController.php

示例2: exits

 /**
  *
  *前台退出
  *
  */
 public function exits()
 {
     session('user_uid', null);
     session('user_name', null);
     session('user_verify', null);
     $this->success("用户退出成功", '__ROOT__/Logo/login.html');
 }
开发者ID:gg1122,项目名称:Dswjcms,代码行数:12,代码来源:HomeAction.class.php

示例3: getValidateToken

 /**
  *
  * @return \Illuminate\Http\Response
  */
 public function getValidateToken()
 {
     if (session('2fa:user:id')) {
         return view('2fa/validate');
     }
     return redirect('login');
 }
开发者ID:cwt137,项目名称:google-laravel-2fa,代码行数:11,代码来源:AuthController.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (session('statut') === 'admin') {
         return $next($request);
     }
     return new RedirectResponse(url('/kadmin/login'));
 }
开发者ID:pumi11,项目名称:astrologonew,代码行数:14,代码来源:IsAdmin.php

示例5: verify

 public function verify($username, $password)
 {
     $credentials = ['username' => $username, 'password' => $password];
     $person = new Person();
     $resp = $person->getUsername($credentials['username']);
     if (!empty($resp)) {
         if (\Hash::check($credentials['password'], $resp['password'])) {
             $auth = true;
         } else {
             //check for old hashing
             if (md5($credentials['password']) == $resp['password']) {
                 //convert old pass to new hashing
                 $resp['password'] = bcrypt($credentials['password']);
                 $id = my_encode($resp['id']);
                 $person->update($id, $resp);
                 $auth = true;
             } else {
                 $auth = false;
             }
         }
     } else {
         //invalid user
         $auth = false;
     }
     if ($auth) {
         $result = $person->respondWithItem($resp, new UserTransformer());
         session()->put('user', $result);
         return my_decode($resp['id']);
     }
     return false;
 }
开发者ID:grepollo,项目名称:dkb_5sp,代码行数:31,代码来源:PasswordGrantVerifier.php

示例6: index

 public function index()
 {
     if (!session('openid_' . $this->token)) {
         $this->info = M('wxuser')->where(array('token' => $this->token))->find();
         vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor');
         vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor');
         $wechat = new Wechat();
         $wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret']));
         $redirect_uri = C('site_url') . '/index.php/Wap/Coupons/index?token=' . $this->token . '&coupon_id=' . $this->coupon_id;
         if (!$_GET['code']) {
             // By sending no options it'll come back here
             $url = $wechat->authorize(array('redirect_uri' => $redirect_uri));
             redirect($url);
         } else {
             try {
                 // Have a go at creating an access token from the code
                 $token = $wechat->access($_GET['code'], array('redirect_uri' => $redirect_uri));
                 // Use this object to try and get some user details (username, full name, etc)
                 $user = $wechat->get_user_info($token);
                 $this->openid = $user->openid;
                 session('openid_' . $this->token, $user->openid);
             } catch (OAuth2_Exception $e) {
                 print_r($e);
                 die;
             }
         }
     } else {
         $this->openid = session('openid_' . $this->token);
     }
     $url = C('site_url') . "/index.php?g=Wap&m=Coupon&a=index&type=1&token=" . $this->token . '&id=' . $this->coupon_id . '&wecha_id=' . $this->openid;
     header('Location:' . $url);
 }
开发者ID:zhaoshengloveqingqing,项目名称:Wechat,代码行数:32,代码来源:CouponsAction.class.php

示例7: xiugai

 public function xiugai()
 {
     $mana = M('manager');
     $name = session('username');
     $ps = $mana->where("username='{$name}'")->getField('password');
     $error = '';
     if (IS_POST) {
         if (intval(I('post.state')) === 1) {
             if (md5(I('post.opassword')) === $ps) {
                 $initial = md5('123456');
                 $mana->where("username='{$name}'")->setField('password', $initial);
                 $this->success('初始化成功', U('index/index'), 2);
             } else {
                 $error = '初始化失败,原密码输入错误';
                 $this->assign('error', $error);
                 $this->display('Admin/index');
             }
         } else {
             if (md5(I('post.opassword')) === $ps) {
                 $nps = md5(I('post.npassword'));
                 $mana->where("username='{$name}'")->setField('password', $nps);
                 $this->success('修改密码成功', U('index/index'), 2);
             } else {
                 $error = '原密码输入错误,修改密码失败';
                 $this->assign('error', $error);
                 $this->display('Admin/index');
             }
         }
     }
 }
开发者ID:longRivers,项目名称:embahust,代码行数:30,代码来源:IndexController.class.php

示例8: autoLogin

 public function autoLogin()
 {
     if (cookie('token')) {
         $token = cookie('token');
         $userId = $token['userId'];
         if (!is_numeric($userId)) {
             return 0;
         }
         $User = D('User');
         $user = $User->find($userId);
         if ($user['userId'] != $userId) {
             return 0;
         }
         if ($token['verify'] != sha1(md5($user['password']))) {
             return 0;
         }
         session('userId', $user['userId']);
         session('userName', $user['userName']);
         session('icon', $user['icon']);
         session('email', $user['email']);
         session('signature', $user['signature']);
         session('score', $user['score']);
         session('registerTime', format_date($user['registerTime']));
         session('lastLoginTime', format_date($user['lastLoginTime']));
         //更新上次登录时间
         $User->where("userId={$userId}")->setField('lastLoginTime', date('Y-m-d H:i:s', time()));
         cookie('token', $token, 864000);
         return 1;
     } else {
         return 0;
     }
 }
开发者ID:AlexanderFeng,项目名称:a-simple-question-and-answer-website,代码行数:32,代码来源:AutoLoginController.class.php

示例9: destroy

 public function destroy($id)
 {
     $wallet = Wallet::findOrFail($id);
     $wallet->delete();
     session()->flash('flash_message', 'Data Deleted!');
     return redirect('wallets');
 }
开发者ID:elzahlan,项目名称:wallet,代码行数:7,代码来源:WalletsController.php

示例10: _initialize

 /**
  * 初始化方法
  * @author jry <598821125@qq.com>
  */
 protected function _initialize()
 {
     //只有ID为1的超级管理员才有权限系统更新
     if (session('user_auth.uid') !== '1') {
         $this->success('');
     }
 }
开发者ID:varphper,项目名称:corethink,代码行数:11,代码来源:SystemUpdateController.class.php

示例11: index

 public function index()
 {
     if (session('?userName')) {
         $this->userName = session('userName');
         //前台显示登录用户名
         $this->logout = session('logout');
         $user['userId'] = session('userId');
         //链接2张表
         /*
          教你如何写thinkphp多表查询语句 (2011-04-07 13:18:44)转载▼
         1、table()函数
         thinkphp中提供了一个table()函数,具体用法参考以下语句:
         $list=$Demo->table('think_blog blog,think_type type')->where('blog.typeid=type.id')->field('blog.id as id,blog.title,blog.content,type.typename as type')->order('blog.id desc' )->limit(5)->select();
         echo $Demo->getLastSql(); //打印一下SQL语句,查看一下
          
         2、join()函数
         看一下代码:
         $Demo = M('artist');
         $Demo->join('RIGHT JOIN think_work ON think_artist.id = think_work.artist_id' );
         //可以使用INNER JOIN 或者 LEFT JOIN 这里一定要注意表名的前缀!
         echo $Demo->getLastSql(); //打印一下SQL语句,查看一下
         */
         $mybooks = D("booklib")->join(' INNER JOIN books ON books.id = booklib.bookId')->where($user)->select();
         $this->assign('mybooks', $mybooks);
         $this->display();
     } else {
         header("Content-Type:text/html; charset=utf-8");
         redirect('login', 0, '请先登录!');
     }
 }
开发者ID:TylerzhangZC,项目名称:novelsWebsite,代码行数:30,代码来源:LibaryAction.class.php

示例12: nocemid

 public function nocemid()
 {
     $nocemid = 'not_eligible';
     session(['key' => $nocemid]);
     return redirect('/client_enrolment')->with('info', 'Clent is not Eligible, enter client details to update register');
     //return view('layouts.results',compact('users'));
 }
开发者ID:Bryoo,项目名称:ProjectCEM,代码行数:7,代码来源:SearchController.php

示例13: callback

 /**
  * 登陆后回调地址
  */
 public function callback()
 {
     $code = I('get.code');
     $type = I('get.type');
     $sns = \ThinkOauth::getInstance($type);
     //腾讯微博需传递的额外参数
     $extend = null;
     if ($type == 'tencent') {
         $extend = array('openid' => I('get.openid'), 'openkey' => I('get.openkey'));
     }
     $token = $sns->getAccessToken($code, $extend);
     //获取第三方Token
     $user_sns_info = \ThinkOauthInfo::$type($token);
     //获取第三方传递回来的用户信息
     $user_sync_info = D('Addons://SyncLogin/SyncLogin')->getUserByOpenidAndType($token['openid'], $type);
     //根据openid等参数查找同步登录表中的用户信息
     $user_sys_info = D('User')->find($user_sync_info['uid']);
     //根据UID查找系统用户中是否有此用户
     if ($user_sync_info['uid'] && $user_sys_info['id'] && $user_sync_info['uid'] == $user_sys_info['id']) {
         //曾经绑定过
         D('Addons://SyncLogin/SyncLogin')->updateTokenByTokenAndType($token, $type);
         D('User')->autoLogin($user_sys_info);
         redirect('http://' . $_SERVER['HTTP_HOST'] . __ROOT__);
     } else {
         //没绑定过,去注册页面
         session('token', $token);
         session('user_sns_info', $user_sns_info);
         $this->assign('user_sns_info', $user_sns_info);
         $this->assign('meta_title', "登陆");
         $this->display(T('Addons://SyncLogin@./default/reg'));
     }
 }
开发者ID:VampireMe,项目名称:corethink,代码行数:35,代码来源:LoginController.class.php

示例14: loaded

 public function loaded()
 {
     $camplog = new CampaignLog(['user' => ['session' => session('_token')], 'device' => ['mac' => "test mac xD"], 'interaction' => ['welcome' => new MongoDate()]]);
     $camplog->save();
     return \Request::all();
     //        return true;
 }
开发者ID:jarm-mcs,项目名称:enera_portal,代码行数:7,代码来源:InteractionsController.php

示例15: submitNickname

 /**
  * 修改昵称提交
  * @author huajie <banhuajie@163.com>
  */
 public function submitNickname()
 {
     //获取参数
     $nickname = I('post.nickname');
     $password = I('post.password');
     empty($nickname) && $this->error('请输入昵称');
     empty($password) && $this->error('请输入密码');
     //密码验证
     $User = new UserApi();
     $uid = $User->login(UID, $password, 4);
     $uid == -2 && $this->error('密码不正确');
     $Member = D('Member');
     $data = $Member->create(array('nickname' => $nickname));
     if (!$data) {
         $this->error($Member->getError());
     }
     $res = $Member->where(array('uid' => $uid))->save($data);
     if ($res) {
         $user = session('user_auth');
         $user['username'] = $data['nickname'];
         session('user_auth', $user);
         session('user_auth_sign', data_auth_sign($user));
         $this->success('修改昵称成功!');
     } else {
         $this->error('修改昵称失败!');
     }
 }
开发者ID:peterleezz,项目名称:test,代码行数:31,代码来源:UserController.class.php


注:本文中的session函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。