本文整理汇总了PHP中Illuminate\Support\Facades\Session::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::set方法的具体用法?PHP Session::set怎么用?PHP Session::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Session
的用法示例。
在下文中一共展示了Session::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeLocale
public function changeLocale($locale)
{
if (array_key_exists($locale, Config::get('app.locales'))) {
Session::set('applocale', $locale);
}
return back();
}
示例2: check
/**
* 后台验证登陆操作
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function check()
{
$username = Input::get('username', null);
$password = Input::get('password', null);
if ($username and $password) {
$user = AdminUser::where('username', '=', $username)->first();
if (count($user)) {
if (sha1($password) == $user->password and $user->enable) {
Session::set('admin_user', $user->username);
Session::set('admin_id', $user->id);
Session::set('admin_level', $user->level);
if ($user->level == 1) {
return redirect('admin/orders/show');
} else {
return redirect('admin/promote/user/center');
}
} else {
flash('密码错误或用户已禁用~');
return redirect()->back();
}
} else {
flash('用户不存在~');
return redirect()->back();
}
} else {
flash('用户名或密码不能为空~');
return redirect()->back();
}
}
示例3: switchLang
public function switchLang($lang)
{
if (array_key_exists($lang, Config::get('languages'))) {
Session::set('applocale', $lang);
}
return Redirect::back();
}
示例4: login
public function login()
{
Session::set('admin_lock_url', null);
$loginForm = new KForm();
$loginForm->addField(FormFieldBase::createByType('login', FormFieldBase::Type_Text)->setRules('required')->setLabel('请输入工号'));
$loginForm->addField(FormFieldBase::createByType('password', FormFieldBase::Type_Password)->setRules('required')->setLabel('请输入密码'));
if (AuthModel::user() !== null) {
return Redirect::action('admin.index');
}
if (Request::isMethod('POST')) {
//是管理员登陆请求
if ($loginForm->validation()) {
$login = $loginForm->value('login');
$password = $loginForm->value('password');
if (AuthModel::attempt(['employee_id' => $login, 'password' => $password])) {
$admin = AuthModel::getUser();
$admin->last_login = new \Carbon\Carbon();
$admin->save();
return Redirect::action('admin.index');
} else {
$loginForm->set_error('password', '错误的用户名或密码');
}
} else {
//
}
}
$this->layout = View::make('laravel-cms::admin-lte/login')->with('form', $loginForm);
}
示例5: update
/**
* @param Request $request
* @return array
*/
public function update($id, $newQtd)
{
$cart = $this->getCart();
$cart->update($id, $newQtd);
Session::set('cart', $cart);
return redirect()->route('cart');
}
示例6: question
public function question()
{
$user = \Auth::user();
$isAjax = \Request::ajax();
$correct_answers = $user->correct_answers;
if (!$isAjax && $correct_answers >= 3) {
Redirect::to('user/start');
}
$data = Question::select('title')->get();
$value = Session::get('index');
if ($value >= count($data) || !$value) {
$value = 1;
}
if ($isAjax) {
Session::set('index', $value + 1);
$value = Session::get('index');
}
$question = \App\Question::with(array('answers' => function ($query) {
$query->select("id", "title", "question_id");
}))->select('id', 'title')->findOrFail($value);
$question['correct_answers'] = $correct_answers;
if ($isAjax) {
return json_encode($question);
}
return view('auth.question', compact('question'));
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$card = Request::all();
$user = Auth::user();
$user_type = $user->user_type;
if ($user_type == 'COMPANY') {
// o bar está abrindo a comanda
$id_company = $user->id_company;
$phone = $card['phone'];
// pega o celular do usuario
$user = User::where('phone', '=', $phone)->get();
// encontra o usuario vinculado a esse celular
foreach ($user as $row) {
$id_user = $row->id_user;
}
} else {
// o usuário está abrindo a propria comanda
$id_user = $user->id_user;
$phone = $user->phone;
$id_company = $card['id_company'];
Session::set('id_company', $id_company);
}
// Gera o HASH da comanda
$full_hash = md5($id_user . $phone . $id_company . microtime() . rand());
$hash_len = strlen($full_hash);
// HASH FINAL
$hash_card = strtoupper(substr($full_hash, $hash_len - 6, 6));
$new_card = ['id_user' => $id_user, 'id_company' => $id_company, 'table' => $card['table'], 'hash_card' => $hash_card];
Card::create($new_card);
return redirect('comandas?card=' . $hash_card);
}
示例8: update
public function update($id, $refresh)
{
$cart = $this->getCart();
$cart->novaQtd($id, $refresh);
Session::set('cart', $cart);
return redirect()->route('cart');
}
示例9: githubLogin
public function githubLogin()
{
$access_token = Input::get('access_token');
$ch = curl_init('https://api.github.com/user');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: token {$access_token}"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_USERAGENT, 'SWAMP');
$response = curl_exec($ch);
$user = json_decode($response);
$account = LinkedAccount::where('user_external_id', '=', $user->id)->first();
if ($account) {
Session::set('github_access_token', $access_token);
$user = User::getIndex($account->user_uid);
if ($user) {
if ($user->isEnabled()) {
$res = Response::json(array('user_uid' => $user->user_uid));
Session::set('timestamp', time());
Session::set('user_uid', $user->user_uid);
return $res;
} else {
return Response::make('User has not been approved.', 401);
}
} else {
return Response::make('Incorrect username or password.', 401);
}
} else {
return Response::make('Account not found.', 401);
}
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string $l
* @return mixed
*/
public function handle($request, Closure $next)
{
//Session::flush();
if (!Session::has('locale')) {
/**
* Get the browser local code and lang code.
*/
$localCode = $request->getPreferredLanguage();
$localLang = substr($localCode, 0, 2);
if (in_array($localLang, $this->lang)) {
Session::set('locale', $localLang);
} else {
Session::set('locale', Config::get('app.locale'));
}
}
/**
* Set the local config.
*/
App::setLocale(Session::get('locale'));
Config::set('app.locale', Session::get('locale'));
/**
* Share variables in view.
*/
if (Config::get('app.locale') == 'fr') {
View::share(['lang' => 'fr', 'langreverse' => 'en']);
} else {
View::share(['lang' => 'en', 'langreverse' => 'fr']);
}
return $next($request);
}
示例11: whitelisted
static function whitelisted()
{
// Detect API Request
//
if (Input::get('api_key') && Input::get('user_uid')) {
if (Config::get('app.api_key') == Input::get('api_key')) {
if (!User::getIndex(Input::get('user_uid'))) {
return false;
}
Session::set('user_uid', Input::get('user_uid'));
return true;
}
return false;
}
// Detect Whitelisted Route
//
foreach (Config::get('app.whitelist') as $pattern) {
if (is_array($pattern)) {
if (Request::is(key($pattern))) {
return in_array(self::method(), current($pattern));
}
} else {
if (Request::is($pattern)) {
return true;
}
}
}
return false;
}
示例12: destroy
public function destroy($id)
{
$cart = $this->getCart();
$cart->remove($id);
Session::set('cart', $cart);
return redirect()->route('cart');
}
示例13: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $lang = 'en')
{
if (array_key_exists($lang, Config::get('languages'))) {
Session::set('applocale', $lang);
}
return Redirect::back();
}
示例14: home
public function home($lang)
{
$langs = ['tr', 'en'];
if (in_array($lang, $langs)) {
Session::set('lang', $lang);
return Redirect::back()->with('lang_msg', 'Your Changeing language');
}
}
示例15: getCart
/**
* @return mixed
*/
private function getCart()
{
if (!Session::has('cart')) {
Session::set('cart', $this->cart);
}
$cart = Session::get('cart');
return $cart;
}