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


PHP Session函数代码示例

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


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

示例1: thumbnail2

 public function thumbnail2(Request $request)
 {
     if ($request->hasFile('thumbnail_file2')) {
         $messages = ['photo.image' => '上传文件必须是图片', 'photo.max' => '上传文件不能大于:maxkb'];
         $this->validate($request, ['photo' => 'image|max:100000'], $messages);
         if ($request->file('thumbnail_file2')->isValid()) {
             $OriginalName = $request->file('thumbnail_file2')->getClientOriginalName();
             $file_pre = sha1(time() . $OriginalName);
             //取得当前时间戳
             $file_suffix = substr(strchr($request->file('thumbnail_file2')->getMimeType(), "/"), 1);
             //取得文件后缀
             $destinationPath = 'uploads';
             //上传路径
             $fileName = $file_pre . '.' . $file_suffix;
             //上传文件名
             Image::make($request->file('thumbnail_file2'))->resize(300, null, function ($constraint) {
                 $constraint->aspectRatio();
             })->save('uploads/thumbnails/' . $fileName);
             $request->file('thumbnail_file2')->move($destinationPath, $fileName);
             $img = new Img();
             $img->name = $fileName;
             $img->save();
             Session()->flash('img2', $fileName);
             return $fileName;
         } else {
             return "上传文件无效!";
         }
     } else {
         return "文件上传失败!";
     }
 }
开发者ID:goyuquan,项目名称:album,代码行数:31,代码来源:AdminController.php

示例2: run

 /**
  * @param integer $v
  * @return bool
  */
 public function run($v)
 {
     $gmt = (int) $v;
     $gmt = $gmt < -14 || $gmt > 12 ? 0 : $gmt;
     Session()->set('timezone', $gmt);
     return true;
 }
开发者ID:cookyii,项目名称:base,代码行数:11,代码来源:TimeZoneAction.php

示例3: delete

 public function delete($id)
 {
     $song = Song::find($id);
     $song->delete();
     Session()->flash('deletesong', 'Song is Deleted');
     return Redirect::to('song');
 }
开发者ID:asifrafeeq,项目名称:Code-Repository,代码行数:7,代码来源:SongController.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @param  string|null $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     $route_uri = $request->route()->getName();
     $route = strstr($route_uri, '.', true);
     if (Auth::check()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             $permission = UserHelper::get_route_permission($route);
             if ($route_uri == $route . '.index' && isset($permission->list) && $permission->list == 1) {
                 return $next($request);
             } elseif ($route_uri == $route . '.show' && isset($permission->view) && $permission->view == 1) {
                 return $next($request);
             } elseif ($route_uri == $route . '.create' && isset($permission->add) && $permission->add == 1) {
                 return $next($request);
             } elseif ($route_uri == $route . '.store' && isset($permission->add) && $permission->add == 1) {
                 return $next($request);
             } elseif ($route_uri == $route . '.edit' && isset($permission->edit) && $permission->edit == 1) {
                 return $next($request);
             } elseif ($route_uri == $route . '.update' && isset($permission->edit) && $permission->edit == 1) {
                 return $next($request);
             } else {
                 Session()->flash('warning_message', 'You do not have permission to access!');
                 if (isset($permission->list) && $permission->list == 1) {
                     return redirect($route);
                 } else {
                     return redirect('/home');
                 }
             }
         }
     } else {
         return redirect()->guest('login');
     }
 }
开发者ID:saj696,项目名称:pipe,代码行数:42,代码来源:Permission.php

示例5: getCurrUser

 /**
  * 判断是否登录及获取当前管理员信息
  */
 protected function getCurrUser()
 {
     $currUser = Session("system_curr_user");
     if (empty($currUser)) {
         return;
     }
     $currUser = unserialize(authcode($currUser));
     if (!isset($currUser['id'])) {
         return;
     }
     $user = D("SysUser")->selectOne($currUser['id']);
     if (!$user) {
         return;
     }
     if (!$user['status']) {
         return;
     }
     // 帐号禁用
     $this->isLogined = true;
     unset($user['password']);
     $user['auth'] = unserialize($user['auth']);
     $user['upTime'] = $currUser['lastTime'];
     $user['upIp'] = $currUser['lastIp'];
     $this->currUser = $user;
 }
开发者ID:dalinhuang,项目名称:edu_hipi,代码行数:28,代码来源:BaseController.class.php

示例6: logout

 public function logout()
 {
     Auth::logout();
     Session()->forget('shopping');
     Session()->forget('nbrProduct');
     return redirect('/')->with(['messageLogout' => trans('app.logoutSuccess'), 'alert' => 'success']);
 }
开发者ID:laetitia91800,项目名称:StarWars,代码行数:7,代码来源:LoginController.php

示例7: GetID

function GetID($type)
{
    $option = Session($type);
    if ($option == "") {
        $option = Cookie($type);
    }
    return $option;
}
开发者ID:uwitec,项目名称:ly-dorice,代码行数:8,代码来源:global.func.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!auth()->user()->hasRole('administrator')) {
         Session()->flash('flash_message_warning', 'Only Allowed for admins');
         return redirect()->back();
     }
     return $next($request);
 }
开发者ID:Bottelet,项目名称:Flarepoint-crm,代码行数:15,代码来源:RedirectIfNotAdmin.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!auth()->user()->can('lead-create')) {
         Session()->flash('flash_message_warning', 'Not allowed to create lead');
         return redirect()->route('leads.index');
     }
     return $next($request);
 }
开发者ID:Bottelet,项目名称:Flarepoint-crm,代码行数:15,代码来源:CanLeadCreate.php

示例10: _initialize

 public function _initialize()
 {
     //用来检查当前用户的合法性
     $type = Session('type');
     if ($type != 2) {
         $this->redirect('Home/Login/index');
     }
 }
开发者ID:vimalmistry,项目名称:Exam,代码行数:8,代码来源:CheckAction.class.php

示例11: getDelete

 public function getDelete($id)
 {
     $sb1 = Sambutan::find($id);
     File::delete('resources/assets/img/sambutan/' . $sb1->foto);
     Sambutan::where('id', $id)->delete();
     \Session()->flash('success', 'Berhasil mengosongkan data');
     return redirect(route('sambutan'));
 }
开发者ID:MediaSaktiTeam,项目名称:MS_kelautan,代码行数:8,代码来源:SambutanController.php

示例12: store

 public function store(Request $request)
 {
     $request->parent_id = empty($request->parent_id) ? 1 : $request->parent_id;
     $messages = ['name.required' => '分类名不能为空'];
     $this->validate($request, ['name' => 'required'], $messages);
     Category::create(['name' => $request->name, 'parent_id' => $request->parent_id]);
     Session()->flash('status', 'category create was successful!');
     return redirect('/admin/categorys/');
 }
开发者ID:goyuquan,项目名称:laravel_admin,代码行数:9,代码来源:CategoryController.php

示例13: store

 public function store(Request $request)
 {
     $token = Session('_token');
     $product_id = $request->get('product_id');
     $quantity = $request->get('quantity');
     $price = Product::find($product_id)->price;
     Cart::create(['product_id' => $product_id, 'quantity' => $quantity, '_token' => $token, 'price' => $price]);
     return redirect('cart')->with(['message' => 'Le produit a été ajouté dans votre panier']);
 }
开发者ID:ivanovamarieta,项目名称:ProjetStarWars,代码行数:9,代码来源:CartController.php

示例14: destroy

 public function destroy($id)
 {
     try {
         $client = Client::findorFail($id);
         $client->delete();
         Session()->flash('flash_message', 'Client successfully deleted');
     } catch (\Illuminate\Database\QueryException $e) {
         Session()->flash('flash_message_warning', 'Client can NOT have, leads, or tasks assigned when deleted');
     }
 }
开发者ID:Bottelet,项目名称:Flarepoint-crm,代码行数:10,代码来源:ClientRepository.php

示例15: showCode

 function showCode()
 {
     $code = Post('code');
     $check = Session('check_num');
     if ($code == $check) {
         echo '0';
     } else {
         echo '1';
     }
 }
开发者ID:uwitec,项目名称:ly-dorice,代码行数:10,代码来源:topic.mod.php


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