本文整理汇总了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');
}
示例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);
}
示例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();
}
示例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.'));
}
}
示例5: delete
public function delete(Product $product)
{
$cart = \Session::get('cart');
unset($cart[$product->slug]);
\Session::put('cart', $cart);
return redirect()->route('cart-show');
}
示例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);
}
示例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'));
}
}
示例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');
}
}
示例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');
}
示例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']);
}
}
示例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');
}
}
示例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');
}
示例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';
}
示例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);
}
示例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);
}
}