本文整理汇总了PHP中Cookie::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Cookie::make方法的具体用法?PHP Cookie::make怎么用?PHP Cookie::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cookie
的用法示例。
在下文中一共展示了Cookie::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created song in storage.
*
* @return Response
*/
public function store()
{
// Set rules for validator
$rules = array("artist" => "required", "title" => "required", "requester" => "required", "link" => "required|url");
// Validate input
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
// TODO: Remember form input...
return Redirect::to('song/create')->withErrors($validator, "song");
}
// Create new song
$song = Input::all();
// Set or unset remember cookie
if (isset($song['remember-requester'])) {
$cookie = Cookie::make("requester", $song['requester']);
} else {
$cookie = Cookie::forget("requester");
}
$artist = DB::getPdo()->quote($song['artist']);
$title = DB::getPdo()->quote($song['title']);
if (Song::whereRaw("LOWER(artist) = LOWER({$artist}) AND LOWER(title) = LOWER({$title})")->count() > 0) {
return Redirect::to('song/create')->with('error', "HEBBEN WE AL!!!")->withCookie($cookie);
}
Song::create($song);
// Set success message
$msg = "Gefeliciteerd! Je nummer is aangevraagd :D";
// Redirect to song index page with message and cookie
return Redirect::to("/")->with("success", $msg)->withCookie($cookie);
}
示例2: dcp
public function dcp()
{
$domain = Domain::whereDomain(Request::getHttpHost())->first();
//$domain = Domain::whereDomain(Request::server("SERVER_NAME"))->first();
$cookie = Cookie::make('domain_hash', $domain->id);
return Redirect::to('/')->withCookie($cookie);
}
示例3: login
public function login()
{
if (UserAuthController::isLogin()) {
return Redirect::to('/welcome');
}
if (Request::isMethod('get')) {
$user_id = Input::get('id', null);
$user_info = tb_users::where('id', $user_id)->first();
if (null == $user_info) {
return View::make('login')->with('deny_info', '链接失效!')->with('deny_user_id', $user_id);
}
// 使用免登录金牌
if (true !== UserAuthController::login($user_id, null)) {
return Response::make(View::make('login'))->withCookie(Cookie::make('user_id', $user_id));
}
return Redirect::to('/welcome');
}
if (Request::isMethod('post')) {
// 使用邀请码登录
$token = Input::get('token');
$user_id = Cookie::get('user_id');
self::recordAccessLog(array('token' => $token, 'user_id' => $user_id));
$error_info = UserAuthController::login($user_id, $token);
if (true !== $error_info) {
return Redirect::back()->with('error_info', $error_info)->withInput();
}
return Redirect::to('/welcome');
}
return Response::make('此页面只能用GET/POST方法访问!', 404);
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$rules = array('private' => 'numeric|required', 'title' => 'max:46|required', 'paste' => 'required', 'expire' => 'required|numeric', 'private' => 'required|numeric', 'tags' => 'max:6|alpha');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
$messages = $validator->messages();
return View::make('paste.form')->withErrors($messages);
}
$new_paste = new Paste();
$new_paste->title = Input::get('title');
$new_paste->token = Str::random(40);
$new_paste->delete_token = Str::random(40);
$new_paste->paste = Input::get('paste');
$new_paste->private = Input::get('private');
date_default_timezone_set('UTC');
$expire_time = date('Y-m-d H:i:s', strtotime(sprintf('now + %s minutes', Input::get('expire'))));
$new_paste->expire = $expire_time;
if (!$new_paste->save()) {
Debugbar::error('Saving failed!');
}
// Check if tags are set
if (Input::has('hidden-tags')) {
$tags = explode(' ', Input::get('hidden-tags'));
foreach ($tags as $key => $tag) {
$tag_model = new Tag();
$tag_model->tag = $tag;
$tag_model->paste_id = $new_paste->id;
$new_paste->tags()->save($tag_model);
}
}
if ($new_paste->id) {
return Redirect::route('paste.show', $new_paste->token)->withCookie(Cookie::make('edittoken', $new_paste->token, 30));
}
return view::make('paste.form', array('page_title' => 'Create a paste'));
}
示例5: login
/**
* login from auth
* @param $login
* @param $email
* @param $token
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public static function login($login, $email, $token, $teams)
{
$expire = 60 * 60 * 24 * 30;
$user = new GithubUser($login, $email, $token, $teams);
self::sessionUser($user);
$user->set();
return Cookie::make(self::$cookieKey, $login, $expire / 60);
}
示例6: createCookie
public function createCookie(Request $request)
{
// create .seeties.me token Cookie
$token = 'JDJ5JDEwJFdDdGRLLlo4OWRCeDlMMTEyUTFtbXVPUDNBN3kxV1VNQ0NEdC9ORXp6WmtSRWkwOTd5WGwy';
$cookie = \Cookie::make('token', $token, 60, null, env('COOKIE_DOMAIN'));
$response = new Response('Hello world');
return $response->withCookie($cookie);
}
示例7: setLocale
public static function setLocale($keyValue)
{
if ($keyValue == '') {
return false;
}
self::$config['locale'] = $keyValue;
Cookie::make('locale', $keyValue, 1440 * 7);
}
示例8: addCookie
public function addCookie($sName, $mxValue, $iTime = 0)
{
if ($iTime > 0) {
$this->_aCookies[] = \Cookie::make($sName, $mxValue, $iTime);
} else {
$this->_aCookies[] = \Cookie::forever($sName, $mxValue);
}
}
示例9: index
public function index()
{
$lang = Cookie::get('lang', 'ru');
$leaders = Leadership::select("lead_fio_{$lang}", "lead_post_{$lang}", "lead_text_{$lang}", "lead_photo", "lead_email", "lead_phone")->get();
$news = News::select('news_id', 'news_alias', "news_title_{$lang}", "updated_at")->orderBy('updated_at', 'DESC')->limit(5)->get();
$cookie = Cookie::make('page', 'about_us', 60 * 24 * 180);
$view = View::make('leaders')->with(array('leaders' => $leaders, 'news' => $news, 'lang' => $lang));
return Response::make($view)->withCookie($cookie);
}
示例10: _setCookie
private function _setCookie()
{
if (Auth::user()->status == 4) {
$cookie = Cookie::make('domain_hash', Auth::user()->domain_id);
} else {
$cookie = Cookie::forget('domain_hash');
}
return $cookie;
}
示例11: facebookpages
public function facebookpages()
{
$code = Input::get('code');
$fb = OAuth::consumer('Facebook');
if (!empty($code)) {
$token = $fb->requestAccessToken($code);
$a = $token->getAccessToken();
$result = json_decode($fb->request('/me/accounts'), true);
$pid = $this->savePages($result);
return Redirect::to('/pages')->withCookie(Cookie::make('pid', $pid, 10));
} else {
$url = $fb->getAuthorizationUri();
return Redirect::to((string) $url);
}
}
示例12: showHome
public function showHome($username)
{
// checkmemberexist
$memberapi = MemberAPI::getMemberByUserName($username);
if (!$memberapi) {
return Redirect::to('https://www.gntclub.com/');
}
$member = User::find($memberapi->member_id);
$page = Page::findBySlug('home')->published()->first();
$cookie = Cookie::make('member_id', $member->member_id, 60);
if ($page) {
return View::make('pages.templates.home', compact('page', 'member'))->withCookie($cookie);
} else {
return View::make('layouts.unpublished');
}
}
示例13: query_restorer
/**
* Will store the current query, if there is no query it will look up in cookies and redirect if found.
*
* @author cr@nodes.dk
* @param array $params
* @return bool|string
*/
function query_restorer($params = [], $blacklist = [])
{
// Store and return
if (!empty(\Request::all())) {
\Cookie::queue(\Cookie::make(md5(\Request::url() . '?' . http_build_query($params)), \Request::all(), 5));
return false;
}
// Retrieve
$query = \Cookie::get(md5(\Request::url() . '?' . http_build_query($params)));
foreach ($blacklist as $key) {
unset($query[$key]);
}
// Redirect with queries
if (!empty($query) && is_array($query)) {
return \Request::url() . '?' . http_build_query($query);
}
return false;
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$locale = \Cookie::get('locale');
if (array_key_exists($locale, $this->app->config->get('app.locales'))) {
$this->app->setLocale($locale);
} else {
\Cookie::queue('locale', 'el', 60 * 24 * 365);
}
$locale = $request->segment(1);
if (array_key_exists($locale, $this->app->config->get('app.locales'))) {
$cookie = \Cookie::make('locale', $locale, 60 * 24 * 365);
$this->app->setLocale($locale);
$segments = $request->segments();
unset($segments[0]);
return $this->redirector->to(implode('/', $segments))->withCookie($cookie);
}
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!($token = $this->auth->setRequest($request)->getToken())) {
return response('Token Not Provided', 400);
}
$user = $this->tokenManager->getUserFromToken($token);
if (!$user instanceof User) {
return $user;
}
// Since we are using cookies, we need to check the JWT xsrfToken against the csrf stored on the user
$key_match = $this->tokenManager->compareTokenKeys($token, $user);
// If keys do not match, invalidate the token and remove it from the cookies
if ($key_match == false) {
// Invalidate the JWT and retrieve the removal cookie
$invalidate = $this->tokenManager->removeToken($token);
return response('Token Keys Do Not Match', 401)->withCookie($invalidate);
}
$cookie = \Cookie::make('jwt', $token, 120, '/', env('SESSION_DOMAIN'), false, false);
return $next($request)->header('Authorization', 'Bearer ' . $token)->withCookie($cookie);
}