/** * 设置主题 * @param Request $request */ public function setTheme(Request $request) { $this->validate($request, ['theme' => 'required']); $cookie = Cookie::make('theme', $request->theme, 10 * 12 * 30 * 24 * 60); //10年 return Redirect::back()->withCookie($cookie); }
/** * Creates a new cookie instance * * @static * @param string $name * @param mixed $value * @param int $minutes * @param string $path * @param string $domain * @param bool $secure * @param bool $httpOnly * @return \Symfony\Component\HttpFoundation\Cookie */ public static function make($name, $value, $minutes = 0, $path = NULL, $domain = NULL, $secure = FALSE, $httpOnly = TRUE) { // Serialize the value $value = @serialize($value); // Create the cookie return parent::make($name, $value, $minutes, $path, $domain, $secure, $httpOnly); }
/** * @param array $content * @return mixed */ public function createCookie(array $content) { if (!isset($this->info[CookieManager::COOKIE_TIME]) || $this->info[CookieManager::COOKIE_TIME] == null) { $cookie = Cookie::forever($this->info[CookieManager::COOKIE_NAME], json_encode($content)); } else { $cookie = Cookie::make($this->info[CookieManager::COOKIE_NAME], json_encode($content), $this->info[CookieManager::COOKIE_TIME]); } return $cookie; }
/** * if a user is deactivated by admin * can not access any route that is under auth middleware * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Cookie::get('blocked') && Cookie::get('blocked') === Crypt::decrypt(Cookie::get('blocked'))) { return redirect('home')->with(['error' => 'messages.error.not_active']); } $user = Auth::user(); if ($user->active === '1') { return $next($request); } Auth::logout(); return redirect('home')->with(['error' => 'messages.error.not_active'])->withCookie(Cookie::make('blocked', Crypt::encrypt('blocked'), '12000')); }
/** * Show the application home page to the user. * * @return Response */ public function index() { $prodotti = $this->prodotto->with('immagini')->orderby('id', 'asc')->get(); if ($this->auth->check()) { $cookie_test = Cookie::make('cookies_check', '1'); $carrello = $this->carrello->where('utente', '=', $this->auth->user()->id)->with('prodotti')->get(); $cartcount = $this->carrello->getCartItemsNumber($this->auth->user()->id); return view('index', compact('prodotti', 'carrello', 'cartcount'))->withCookie($cookie_test); } else { return view('index', compact('prodotti')); } }
public function getGlobalCartOrder($createIfNone = false) { if (Cookie::has('goprop_order_id') && !isset($this->_currentOrder)) { $order = Order::where('id', Cookie::get('goprop_order_id'))->where('status', Order::STATUS_CART)->whereNull('property_id')->first(); $this->_currentOrder = $order; } if (empty($this->_currentOrder)) { if ($createIfNone) { $order = new Order(); $order->status = Order::STATUS_CART; $order->save(); $this->_currentOrder = $order; $cookie = Cookie::make('goprop_order_id', $order->id, 25200); Cookie::queue($cookie); } } return $this->_currentOrder; }
/** * Show the application dashboard to the user. * * @return Response */ public function index(Request $request) { if (!isset($_SESSION["timer"])) { $_SESSION["timer"] = time(); } $user_id = Auth::user()->id; if (is_null($user_id)) { return redirect("/auth/login")->withErrors(["Access not allowed, you must login"]); } $notes = Notes::where('user_id', $user_id)->first()->mynotes; $tbd = Tbd::where('user_id', $user_id)->first()->mytbd; $linksArray = Websites::where('user_id', $user_id)->first()->mylink; $email = Auth::user()->email; $website = explode(',', $linksArray); $image = DB::table('myimages')->where('user_id', $user_id)->lists('myimage'); Cookie::queue(Cookie::make('loginEmail', $email, 42 * 60)); return view('home', compact('notes', 'tbd', 'website', 'image')); }
public function girisKontrol() { #region E-mail ve Şifre kontrolü $data = Input::all(); $kural = array('email' => 'required|email', 'password' => 'required'); $dogrulama = \Validator::Make($data, $kural); if ($dogrulama->fails()) { // gönderilen verilerde hata var return \Redirect::to('admin/')->withErrors($dogrulama)->withInput(); } #endregion! #region Kullanıcı var mı? $bilgi = array(); $gelen = DB::select('select * from admin where mail=? and sifre=?', array($data["email"], md5($data["password"]))); if (count($gelen) == 0) { return Redirect::to('admin'); } $bilgi = $gelen[0]; #endregion #region Kullanıcı varsa ne olacak? /*Session ile bilgilerini tut. Eğer "BENİ HATIRLA" ile giriş yaptı ise Cookie de oluştur. Kullanıcı yoksa giriş sayfasına yönlendir.*/ if ($gelen) { if (isset($data["remember"])) { Session::put('id', $bilgi->id); Session::put('email', $data["email"]); Session::put('password', $data["password"]); Cookie::queue(Cookie::make('user', array($bilgi->id, $data["email"], $data["password"], 24000))); // return Redirect::to('admin/anasayfa'); } else { Session::put('id', $bilgi->id); Session::put('email', $data["email"]); Session::put('password', $data["password"]); // return Redirect::to('admin/anasayfa'); } } else { return view('admin'); } #endregion }
protected function verified() { // Valid Code || Submitted Proof? $payload = Cookie::get('twilio::phone'); // Valid Request if ($payload['code'] == Input::get('code') || $payload['valid'] === true) { // Validate. $payload['valid'] = true; // Update Model $this->phone = $payload; // Fire "Phone Added" Event \Event::fire('user.phoneVerified', $payload); // Respond w/ Object for a 5 Minute TTL return $this->respond($payload, 200)->withCookie(Cookie::make('twilio::phone', $payload, 5)); } else { return false; } }
/** * 提交登录表单 * @return Response */ public function postLogin() { $username = Input::get('email-log'); $password = Input::get('password-log'); $result = DB::table('user_account')->where('loginname', $username)->pluck('passwd'); if (empty($result)) { //邮箱未注册 return response()->json(['msg' => '邮箱未注册', 'status' => '1', 'result' => $result]); } else { if ($result == $password) { $uid = DB::table('user_account')->where('loginname', $username)->pluck('uid'); return response()->json(['msg' => '登录成功', 'status' => '3', 'result' => $username])->withCookie(Cookie::make('uid', $uid, 60)); } else { //密码错误 return response()->json(['msg' => '密码错误', 'status' => '2', 'result' => $username]); } } }