本文整理匯總了PHP中Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::addCookieToResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP VerifyCsrfToken::addCookieToResponse方法的具體用法?PHP VerifyCsrfToken::addCookieToResponse怎麽用?PHP VerifyCsrfToken::addCookieToResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Foundation\Http\Middleware\VerifyCsrfToken
的用法示例。
在下文中一共展示了VerifyCsrfToken::addCookieToResponse方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addCookieToResponse
/**
* Add the CSRF token to the response cookies.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Response $response
* @return \Illuminate\Http\Response
*/
protected function addCookieToResponse($request, $response)
{
if ('array' !== config('session.driver')) {
return parent::addCookieToResponse($request, $response);
}
return $response;
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$skip = array('login');
foreach ($skip as $key => $route) {
//skip csrf check on route
if ($request->is($route)) {
return parent::addCookieToResponse($request, $next($request));
}
}
return parent::handle($request, $next);
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// Only enable CSRF on these routes:
$enable_for = [];
foreach ($enable_for as $route) {
if ($request->is($route)) {
return parent::handle($request, $next);
}
}
return parent::addCookieToResponse($request, $next($request));
}