本文整理汇总了PHP中Illuminate\Http\Response::withCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::withCookie方法的具体用法?PHP Response::withCookie怎么用?PHP Response::withCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Response
的用法示例。
在下文中一共展示了Response::withCookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveUser
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function saveUser(Response $response, Request $request)
{
$despo = new Valentine();
$Userexists = Valentine::getExistingUser($request->input('id'));
if (is_object($Userexists)) {
if (!is_null($Userexists->interests)) {
$response->setContent('/findlove');
$response->withCookie(cookie()->forever('shy_first_college', $Userexists->college));
} else {
$response->setContent('/profile/complete');
}
$response->withCookie(cookie()->forever('shy_first_id', $Userexists->id));
$response->withCookie(cookie()->forever('shy_first_sex', $Userexists->sex));
} else {
$despo->name = $request->input('name');
$despo->age = $request->input('birthday', '');
$despo->sex = $request->input('gender');
$despo->userId = $request->input('id');
$despo->tel = $request->input('name');
$despo->social = $request->input('social');
$despo->url = $request->input('link');
$despo->email = $request->input('email');
if ($despo->save()) {
$response->setContent('/profile/complete');
$response->withCookie(cookie()->forever('shy_first_id', $despo->id));
$response->withCookie(cookie()->forever('shy_first_sex', $request->input('sex')));
}
}
return $response;
}
示例2: setViewWithDR
private function setViewWithDR($view)
{
$response = new Response($view->with('dr', $this->dr));
$response->withCookie(cookie('to', $this->dr->to->format('Y-m-d'), 45000));
$response->withCookie(cookie('fr', $this->dr->fr->format('Y-m-d'), 45000));
$response->withCookie(cookie('date', $this->dr->date->format('Y-m-d'), 45000));
return $response;
}
示例3: store
public function store()
{
$preferences = Request::all();
$response = new Response('OK');
$response->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_AMOUNT, $preferences['amount'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_PERIOD, $preferences['period'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXCDB, $preferences['taxcdb'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXLCI, $preferences['taxlci'], PreferencesVO::PREFERENCES_LIFESPAN));
return $response;
}
示例4: setVisitor
/**
* [nextDate description]
* @return [type] [description]
*/
public function setVisitor(Request $request)
{
// Fetch cookie
$cvuid_val = $request->cookie('CVUID');
// Check if cookie exists
if (isset($cvuid_val)) {
$u = Visitor::where('session', '=', $cvuid_val)->first();
// Check if user is alive
if ($u != Null && $u->count() > 0) {
$uid = $cvuid_val;
$u->touch();
//touch user to keep alive
} else {
// Create new user cause seems dead
$uid = uniqid('_csnvaka', true);
$v = new Visitor();
$v->session = $uid;
$v->save();
}
} else {
// Create new user, cause totaly new :)
$uid = uniqid('_csnvaka', true);
$v = new Visitor();
$v->session = $uid;
$v->save();
}
// Create response with cookie
$response = new Response($uid);
$response->withCookie(cookie('CVUID', $uid, 720));
return $response;
}
示例5: getIndex
public function getIndex(Request $request)
{
$data = [];
$userControllerObj = new UserController();
$cookie = $userControllerObj->checkCookie($request);
$data['categories'] = Categories::getCategories();
if ($cookie === 0) {
return View::make('index', $data);
} else {
if ($cookie === -1) {
$response = new Response('Your cookie is invalid, We have cleared it for you, Refresh to re-login to NEUP-Channel');
return $response->withCookie('neupchan', "", -1);
} else {
if ($cookie->shortCookie === NULL) {
$shortCookie = $cookie->short_cookie;
$data['firstLogin'] = true;
} else {
$shortCookie = $cookie->shortCookie;
$data['lastLoginIP'] = $cookie->last_login_ip;
}
}
}
$data['shortCookie'] = $shortCookie;
//return View::make('index', $data)->withCookie(cookie('neupchan', $cookie, 90 * 24 * 60));
$response = new Response(view('index', $data));
if (isset($data['firstLogin'])) {
return $response->withCookie('neupchan', $cookie, 90 * 24 * 60);
} else {
return $response;
}
}
示例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: getAddCookie
/**
* 获取Cookie
*/
public function getAddCookie()
{
$response = new Response();
//第一个参数是cookie名,第二个参数是cookie值,第三个参数是有效期(分钟)
$response->withCookie(cookie('website', 'LaravelAcademy.org', 1));
//如果想要cookie长期有效使用如下方法
//$response->withCookie(cookie()->forever('name', 'value'));
return $response;
}
示例8: getIndex
/**
* Responds to requests to GET /users
*/
public function getIndex(CookieJar $cookiejar, Request $request)
{
//return Auth::user()->email;
event(new DevCheckedIn(Auth::user()));
$response = new Response(view('signup')->with(['data' => Auth::user()]));
if (Cookie::get('success') !== false) {
$response->withCookie(Cookie::forget('success'));
return $response;
}
return $response;
// return view("users");
}
示例9: add
public function add(Request $request)
{
$info = $request->info;
$name = $info['name'];
if (null !== Cookie::get($name)) {
$existCart = json_decode(Cookie::get($name), true);
$existCart[$name]['qty']++;
$cartjson = json_encode($existCart);
} else {
$cartvalue[$name]['price'] = $info['price'];
$cartvalue[$name]['qty'] = 1;
$cartjson = json_encode($cartvalue);
}
$response = new Response(view('welcome'));
$response->withCookie(cookie($name, $cartjson, 86400));
return $response;
}
示例10: destroyCookie
/**
* delete the count cookie
* @return Response object
*/
public function destroyCookie()
{
$cookie = Cookie::forget('count');
$response = new Response($cookie);
$response->withCookie($cookie);
return $response;
}
开发者ID:umarhussain15,项目名称:web_semester_project_integration_repo_Jan16,代码行数:11,代码来源:DonnerController.php
示例11: attachCookieToResponse
/**
* Attaching A New Cookie To A Response
*
* @param Request $request
* @return Response
*/
public function attachCookieToResponse(Response $response)
{
$response = new Illuminate\Http\Response('Hello World');
$response->withCookie(cookie('name', 'value', 300));
var_dump($response);
}
示例12: show
//.........这里部分代码省略.........
// Set the privacy message
$privateMessage = 'This event is private';
// Return view
return \View::make('events.private')->with('privateMessage', $privateMessage);
}
// If the privacy setting is by invite only
} elseif ($private === true && $key === 'byInvite') {
// Set privacy message
$privateMessage = 'This event is private and only viewed by an invite';
// Return view
return \View::make('events.private')->with('privateMessage', $privateMessage);
}
}
}
}
} else {
// If the user is not logged in
if (!\Auth::check() && $private === true) {
// Return view login with the title of the event and the slug
return \Redirect::route('login')->with('warning_message', 'In order to view ' . $events['title'] . ' you must log in')->with('previous_page', $events['slug']);
}
// While the one of the 3 privacy settings are true
while (list($key, $value) = each($events['meta']['private'])) {
if ($value === true) {
$private = true;
// If the privacy setting is shareableLink
if ($private === true && $key === 'shareableLink') {
// Set the privacy message
$privateMessage = 'This event is private and only viewed with a private link';
// Return view
return \View::make('events.private')->with('privateMessage', $privateMessage);
// Else if the privacy setting is friends only
} elseif ($private === true && $key === 'friendsOnly') {
// Set the privacy message
$privateMessage = 'This event is private';
// Return view
return \View::make('events.private')->with('privateMessage', $privateMessage);
// If the privacy setting is by invite only
} elseif ($private === true && $key === 'byInvite') {
// Set the privacy message
$privateMessage = 'This event is private and only viewed by an invite';
// Return view
return \View::make('events.private')->with('privateMessage', $privateMessage);
}
}
}
}
if (!empty($events)) {
// Set default photo
$defaultPhoto = null;
// Use featured photo if available
if (isset($events['featuredPhoto'])) {
$defaultPhoto = $events['featuredPhoto'];
}
// Use first photo if available and featured photo is not available
if ($defaultPhoto == null && isset($events['photos'][0])) {
$defaultPhoto = $events['photos'][0];
}
// Sets events meta data
$meta = $this->setMetaData($events);
$metaTitle = $meta['metaTitle'];
$metaDescription = $meta['metaDescription'];
$metaKeywords = $meta['metaKeywords'];
// Set ticket type to ticket or reservation
$ticketType = $this->setTicketType($events);
$tickets = $ticketType['tickets'];
$reservations = $ticketType['reservations'];
// Shows related events
$relatedEvents = $this->setRelatedEvents($events, $api);
// Set times default
$times = [];
// Set times Id default
$eventTimeIdSelected = null;
// Set times Id default
$timesId = [];
// Times array build and set
foreach ($events['times'] as $key => $value) {
// Set key if set to null
if ($eventTimeIdSelected === null) {
$eventTimeIdSelected = $value['id'];
}
$key = $value['id'];
$value = date('M d @ g:ia', strtotime($value['start']));
$times[$key] = $value;
}
// View data
$data = ['address' => $address, 'attendeeInfo' => $attendeeInfo, 'attendeeList' => $attendeeList, 'eventId' => $eventId, 'events' => $events, 'times' => $times, 'tickets' => $tickets, 'reservations' => $reservations, 'eventTimeIdSelected' => $eventTimeIdSelected, 'timesId' => $timesId, 'friends' => isset($friends) ? $friends : [], 'defaultPhoto' => $defaultPhoto, 'relatedEvents' => $relatedEvents, 'hash' => $hash, 'metaKeywords' => $metaKeywords, 'attendingStatus' => $attendingStatus, 'ownedEvent' => $ownedEvent, 'metaDescription' => $metaDescription, 'metaTitle' => $metaTitle, 'isAdmin' => $isAdmin, 'id' => $id, 'slug' => $slug, 'isAccessedByPrivateLink' => $isAccessedByPrivateLink];
// Check if user is signed in
if (\Auth::check()) {
$user = $api->index('users/' . \Auth::user()->id . '?with[]=ticketInventories&with[]=stripeManagedAccounts&auth_user_id=' . \Auth::user()->id);
$user = $user['data']['user'];
}
// The view
$view = \View::make('events.show', $data)->with(['data' => $data, 'user' => isset($user) ? $user : null]);
// Instanciate response
$response = new Response($view);
// Return response
return $response->withCookie(\Cookie::make('suarayrequestfrom', $setFriendCookie, 43829.1))->withCookie(\Cookie::forget('purchaseCookieData'));
}
}
示例13: render
/**
* Return a template with content.
*
* @param integer $statusCode
* @throws UnknownLayoutFileException
* @return Response
*/
public function render($statusCode = 200)
{
// Fire the event before render.
$this->fire('after', $this);
// Flush asset that need to serve.
$this->asset->flush();
// Layout directory.
$layoutDir = $this->getConfig('containerDir.layout');
$path = $this->getThemeNamespace($layoutDir . '.' . $this->layout);
if (!$this->view->exists($path)) {
throw new UnknownLayoutFileException("Layout [{$this->layout}] not found.");
}
$content = $this->view->make($path)->render();
// Append status code to view.
$content = new Response($content, $statusCode);
// Having cookie set.
if ($this->cookie) {
$content->withCookie($this->cookie);
}
return $content;
}
示例14: setApiResponse
/**
* @param $proxyResponse
* @param $cookie
* @return Response
*/
private function setApiResponse($proxyResponse, $cookie)
{
$response = new Response($proxyResponse->getContent(), $proxyResponse->getStatusCode());
if ($proxyResponse->getStatusCode() === 200) {
if ($this->callMode === ProxyAux::MODE_LOGIN) {
$response->setContent(json_encode($this->successAccessToken()));
}
if (isset($cookie)) {
$response->withCookie($cookie);
}
}
return $response;
}
示例15: getTkIndex
public function getTkIndex(Request $request)
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] === '127.0.0.1') {
$timelogs = Timelog::with('employee.branch')->orderBy('datetime', 'DESC')->take(20)->get();
} else {
$timelogs = Timelog::with(['employee' => function ($query) {
$query->with(['branch' => function ($query) {
$query->select('code', 'descriptor', 'id');
}, 'position' => function ($query) {
$query->select('code', 'descriptor', 'id');
}])->select('code', 'lastname', 'firstname', 'branchid', 'positionid', 'id');
}])->select('timelog.*')->join('hr.employee', function ($join) {
$join->on('timelog.employeeid', '=', 'employee.id')->where('employee.branchid', '=', $this->_branchid);
})->orderBy('datetime', 'DESC')->take(20)->get();
}
//return $timelogs;
//if(count($timelogs) <= 0)
// return redirect()->route('auth.getlogin');
$response = new Response(view('tk.index', compact('timelogs')));
//->with('timelogs', $timelogs));
$response->withCookie(cookie('branchid', $this->_branchid, 45000));
$response->withCookie(cookie('code', session('user.branchcode'), 45000));
return $response;
//return view('tk.index', compact($timelogs));//->with('timelogs', $timelogs);
}