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


PHP Session::put方法代码示例

本文整理汇总了PHP中App\Http\Controllers\Session::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::put方法的具体用法?PHP Session::put怎么用?PHP Session::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Controllers\Session的用法示例。


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

示例1: login

 /**
  * @param Request $request
  * @return \Response
  */
 public function login(Request $request)
 {
     if ($request->has('identifier') && $request->has('password')) {
         switch (\Auth::verify(['identifier' => $request->get('identifier'), 'password' => $request->get('password')], $request->has('remember'))) {
             case Verify::SUCCESS:
                 \Session::put('background', auth()->user()->background);
                 return redirect()->back()->with('success', 'Login successful');
             case Verify::INVALID_CREDENTIALS:
                 return redirect()->back()->with('error', 'Invalid credentials');
             case Verify::DISABLED:
                 $user = User::whereUsername($request->get('identifier'))->orWhere('email', $request->get('identifier'))->first();
                 if ($user->banend->eq(Carbon::create(0, 0, 0, 0, 0, 0))) {
                     return redirect()->back()->with('error', 'You are permanently banned for \'' . $user->banreason . '\'.');
                 }
                 // if ban expired unban and relogin.
                 if ($user->banend->lt(Carbon::now())) {
                     $user->banend = null;
                     $user->disabled = 0;
                     $user->banreason = null;
                     $user->save();
                     return $this->login($request);
                 }
                 return redirect()->back()->with('error', 'You are banned for another ' . $user->banend->diffForHumans(null, true) . '. Reason: \'' . $user->banreason . '\'');
             case Verify::UNVERIFIED:
                 return redirect()->back()->with('error', 'Please verify your account');
         }
     }
     return redirect()->back()->with('error', 'Missing credentials');
 }
开发者ID:sirx,项目名称:w0bm.com,代码行数:33,代码来源:UserController.php

示例2: get_instagram

 public function get_instagram()
 {
     // make sure user is logged in
     if (!\Auth::user()) {
         return \Redirect::to('/')->withInput()->withErrors('You must be logged in to access the Instagram panel.');
     }
     // configure the API values
     $auth_config = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'redirect_uri' => REDIRECT_URI);
     // create a new Auth object using the config values
     $auth = new \Instagram\Auth($auth_config);
     // authorize app if not already authorized
     if (!\Input::get('code')) {
         $auth->authorize();
     }
     // get the code value returned from Instagram
     $code = \Input::get('code');
     $title = 'ImgHost - Instagram';
     // save the access token if not already saved
     if (!\Session::get('instagram_access_token')) {
         \Session::put('instagram_access_token', $auth->getAccessToken($code));
     }
     // create a new Instagram object
     $instagram = new \Instagram\Instagram();
     // set the access token on the newly created Instagram object
     $instagram->setAccessToken(\Session::get('instagram_access_token'));
     // get the ID of the authorized user
     $current_user = $instagram->getCurrentUser();
     // access the media of the authorized user
     $media = $current_user->getMedia();
     $db_images = \DB::table('images')->get();
     return \View::make('instagram')->with('title', $title)->with('instagram_images', $media)->with('db_images', $db_images);
 }
开发者ID:slopedoo,项目名称:laravel-5,代码行数:32,代码来源:InstagramController.php

示例3: doLogin

 public function doLogin(Request $request)
 {
     // dd($request);
     //get the users credentials
     $credentials = ['login' => $request->email];
     //check if there is a match for the email and pword provided
     $user = \Sentinel::findByCredentials($credentials);
     //if there is no match redirect to login page ith input
     if (is_null($user)) {
         // dd($user);
         session()->flash('flash_message', 'Login failure.');
         session()->flash('flash_message_important', true);
         return \Redirect::back()->withInput();
     }
     //attempt to login
     $login = isset($request->remember_me) && $request->remember_me == 1 ? $user = \Sentinel::login($user) : ($user = \Sentinel::login($user));
     // store user info in session
     $user = \Sentinel::getUser();
     \Session::put('user', $user);
     //store user's role in session
     $roles = [];
     foreach ($user->roles as $role) {
         $roles[] = $role;
     }
     \Session::put('roles', $roles);
     //store session and term info in session
     $term_info = DB::table('current_term')->orderBy('created_at', 'desc')->first();
     if (null !== $term_info) {
         \Session::put(['current_session' => $term_info->session, 'current_term' => $term_info->term]);
     }
     return \Redirect::intended();
 }
开发者ID:umahatokula,项目名称:academia,代码行数:32,代码来源:loginController.php

示例4: registro

 public function registro(Request $request)
 {
     $usuario = Usuario::existe($request->input('usuario'));
     $error_registro = false;
     if (count($usuario) == 0) {
         if (strlen(str_replace("\"", "", str_replace("'", "", $request->input('pass1')))) > 0 && strlen(str_replace("\"", "", str_replace("'", "", $request->input('pass2')))) > 0) {
             if (strcmp(str_replace("\"", "", str_replace("'", "", $request->input('pass1'))), str_replace("\"", "", str_replace("'", "", $request->input('pass2')))) == 0) {
                 $id_usuario = Usuario::registrarUsuario($request);
                 \Session::put('logeado', true);
                 \Session::put('usuario', $request->input('usuario'));
                 \Session::put('id_usuario', $id_usuario);
                 \Session::put('carrito', array());
                 \Session::put('total_compra', 0);
                 return \Redirect::to('/')->with(array('registro_exitoso' => true, 'mensaje' => 'Felicidades, su cuenta ha sido creada'));
             } else {
                 $error_registro = true;
                 return \Redirect::back()->with(array('error_registro' => $error_registro, 'mensaje' => 'Las contraseñas no coinciden.'));
             }
         } else {
             $error_registro = true;
             return \Redirect::back()->with(array('error_registro' => $error_registro, 'mensaje' => 'Las contraseñas no pueden estar vacias.'));
         }
     } else {
         $error_registro = true;
         return \Redirect::back()->with(array('error_registro' => $error_registro, 'mensaje' => 'El nombre de usuario ya existe.'));
     }
 }
开发者ID:GriseldaCuevas,项目名称:WebShop,代码行数:27,代码来源:UsuarioController.php

示例5: delete

 public function delete(Product $product)
 {
     $cart = \Session::get('cart');
     unset($cart[$product->slug]);
     \Session::put('cart', $cart);
     return redirect()->route('cart-show');
 }
开发者ID:edgarxene,项目名称:Store-X,代码行数:7,代码来源:CartController.php

示例6: __construct

 public function __construct()
 {
     $this->middleware('ipblocked');
     $driver = config('database.default');
     $database = config('database.connections');
     $this->db = $database[$driver]['database'];
     $this->dbuser = $database[$driver]['username'];
     $this->dbpass = $database[$driver]['password'];
     $this->dbhost = $database[$driver]['host'];
     if (\Auth::check() == true) {
         if (!\Session::get('gid')) {
             \Session::put('uid', \Auth::user()->id);
             \Session::put('gid', \Auth::user()->group_id);
             \Session::put('eid', \Auth::user()->email);
             \Session::put('ll', \Auth::user()->last_login);
             \Session::put('fid', \Auth::user()->first_name . ' ' . \Auth::user()->last_name);
             \Session::put('themes', 'sximo-light-blue');
         }
     }
     if (!\Session::get('themes')) {
         \Session::put('themes', 'sximo');
     }
     if (defined('CNF_MULTILANG') && CNF_MULTILANG == 1) {
         $lang = \Session::get('lang') != "" ? \Session::get('lang') : CNF_LANG;
         \App::setLocale($lang);
     }
     $data = array('last_activity' => strtotime(Carbon::now()));
     \DB::table('tb_users')->where('id', \Session::get('uid'))->update($data);
 }
开发者ID:Gadurp1,项目名称:Final-420-Project,代码行数:29,代码来源:Controller.php

示例7: autoLogin

 private function autoLogin()
 {
     try {
         if (\Session::has('userID')) {
         } else {
             //try set session from cookies if no session
             if (!empty(\Cookie::get('userID'))) {
                 $field = array('field' => '_id', 'value' => (string) \Cookie::get('userID'));
                 if (Auth::isExists($field)) {
                     \Session::put('userID', \Cookie::get('userID'));
                     //
                     //return \Response::make()->withCookie(\Cookie::make('userID', \Cookie::get('userID') , self::COOKIE_EXPIRE));
                 } else {
                     throw new AuthCheckException('username', 'auth.username.doesnt.exist');
                 }
             } else {
                 //\Session::forget('userID')->withCookie(\Cookie::forget('userID'))->withCookie(\Cookie::forget('userID'));
                 throw new AuthCheckException('userid', 'auth.userid.doesnt.exist');
             }
         }
     } catch (Exception $e) {
         $return = \Response::json(["message" => "Session logout!"], 400);
         \Session::forget('userID');
         return $return->withCookie(Cookie::forget('userID'))->withCookie(Cookie::forget('userID'));
     }
 }
开发者ID:stevetay,项目名称:MCMC,代码行数:26,代码来源:RegionController.php

示例8: addTask

 public function addTask(Request $request)
 {
     $parseTask = new ParseObject("Task");
     $parseCropQuery = new ParseQuery("Crop");
     $parseCropQuery->equalTo("cropName", $request->input('crop'));
     $crop = $parseCropQuery->first();
     $parseQuery = new ParseQuery("Task");
     $parseQuery->equalTo("cropName", $crop);
     $parseQuery->equalTo("taskDesc", $request->input('taskName'));
     if ($parseQuery->count() > 0) {
         return redirect('/tasks');
     }
     $parseTask->set("cropName", $crop);
     $parseTask->set("taskDesc", $request->input('taskName'));
     $parseTask->set("taskDuration", $request->input('taskDuration'));
     $parseTask->set("taskStart", $request->input('taskStart'));
     try {
         $parseTask->save();
         \Session::put('message', 1);
         return redirect('tasks');
     } catch (ParseException $e) {
         \Session::put('message', -1);
         return redirect('tasks');
     }
 }
开发者ID:whizdummy,项目名称:Farmers-Plaza-Web,代码行数:25,代码来源:TasksController.php

示例9: update

 public function update(Product $product, $quantity)
 {
     $cart = \Session::get('cart');
     $cart[$product->slug]->quantity = $quantity;
     \Session::put('cart', $cart);
     return redirect()->route('cart-show');
 }
开发者ID:kazamax,项目名称:tienda,代码行数:7,代码来源:CartController.php

示例10: login

 public function login()
 {
     $aRequest = \Input::all();
     $sUsername = $aRequest['username'];
     $sPassword = $aRequest['password'];
     //Check if there's a user with this name, if yes, get all needed information for them
     $aResult = DB::table('users')->where(array('username' => $sUsername))->get(array('*'));
     if (!empty($aResult)) {
         //If execution reached here then the user is normal user.
         $sUserType = 'user';
     }
     if (empty($aResult)) {
         //Check if the user is a restaurant
         $aResult = DB::table('restaurants')->where(array('username' => $sUsername))->get(array('*'));
         $sUserType = 'restaurant';
         \Session::put('loggedin', 'true');
         \Session::put('username', $sUsername);
         \Session::put('id_user', $aResult[0]->id_restaurant);
         \Session::put('user_type', $sUserType);
         //PUT THE SESSION FOR THE RESTAURANT
         return redirect()->intended('/');
     }
     if (empty($aResult)) {
         return redirect('login')->withErrors('User not found!');
     }
     if (Hash::check($sPassword, $aResult[0]->password)) {
         \Session::put('loggedin', 'true');
         \Session::put('username', $sUsername);
         \Session::put('id_user', $aResult[0]->id_user);
         \Session::put('user_type', $sUserType);
         return redirect()->intended('/');
     } else {
         return redirect('login')->withErrors(['Password is wrong!!', 'Error']);
     }
 }
开发者ID:4Bara,项目名称:Fooder-Food-ordering-website-,代码行数:35,代码来源:loginController.php

示例11: index2

 public function index2()
 {
     $level = null;
     if (empty(Auth::user()->level->nama)) {
         \Session::put('error', 'You are not authorized!');
         return \Redirect('logout');
     } else {
         $level = Auth::user()->level->nama;
     }
     if ($level == 'Admin') {
         return View('members.admin.index');
     }
     if ($level == 'Supervisor') {
         return Redirect::route('members.supervisor.laporan.index');
     }
     if ($level == 'Technician') {
         return Redirect::route('members.technician.index');
     }
     if ($level == 'User') {
         return Redirect::route('members.user.laporan.index');
     }
     if ($level == 'Data Entry') {
         return View('members.dataentry.index');
     }
     if ($level == null) {
         return Redirect::route('logout');
     }
 }
开发者ID:suhairi,项目名称:maintenance,代码行数:28,代码来源:UserController.php

示例12: create

 public function create(Todo $todo)
 {
     $text = Input::get('text');
     if (!$todo->createTodo($text, false)) {
         Session::put("error", "Kon todo niet aanmaken");
     }
     return redirect('todo');
 }
开发者ID:Anton-Patokin,项目名称:web-backend-oplossingen,代码行数:8,代码来源:TodoController.php

示例13: filter

 /**
  * Applies a filter
  * 
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function filter(Request $request)
 {
     $filter = $request->input('filter');
     \Session::put('filter', $filter);
     \Session::flash('status', 'The filter has been updated');
     // Indicate success
     return '1';
 }
开发者ID:no-global-state,项目名称:Mabbit,代码行数:14,代码来源:Issues.php

示例14: catch_all

 public function catch_all($param)
 {
     if (view()->exists('static.' . $param)) {
         \Session::put('path', $param);
         $title = prepTitle($param, 'Kastner & Pallavicino');
         return view('static.' . $param, compact('title'));
     }
     // return $param;
     abort(404);
 }
开发者ID:sidis405,项目名称:KP,代码行数:10,代码来源:StaticController.php

示例15: loginAPI

 public function loginAPI()
 {
     if (Input::get('name') == "admin" && sha1(Input::get('password')) === "05fe7461c607c33229772d402505601016a7d0ea") {
         $return = \Response::json(["status" => "ok", "message" => "Sucessfull Login!"], 200);
         \Session::put('tempuser.token', sha1(Input::get('password')));
         return $return;
     } else {
         return \Response::json(['error' => true, 'message' => "Error, Invalid name or password"], 400);
     }
 }
开发者ID:stevetay,项目名称:MCMC,代码行数:10,代码来源:ApiController.php


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