"Fossies" - the Fresh Open Source Software Archive

Member "framework-8.64.0/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php" (12 Oct 2021, 970 Bytes) of package /linux/www/laravel-framework-8.64.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AddQueuedCookiesToResponse.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Illuminate\Cookie\Middleware;
    4 
    5 use Closure;
    6 use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
    7 
    8 class AddQueuedCookiesToResponse
    9 {
   10     /**
   11      * The cookie jar instance.
   12      *
   13      * @var \Illuminate\Contracts\Cookie\QueueingFactory
   14      */
   15     protected $cookies;
   16 
   17     /**
   18      * Create a new CookieQueue instance.
   19      *
   20      * @param  \Illuminate\Contracts\Cookie\QueueingFactory  $cookies
   21      * @return void
   22      */
   23     public function __construct(CookieJar $cookies)
   24     {
   25         $this->cookies = $cookies;
   26     }
   27 
   28     /**
   29      * Handle an incoming request.
   30      *
   31      * @param  \Illuminate\Http\Request  $request
   32      * @param  \Closure  $next
   33      * @return mixed
   34      */
   35     public function handle($request, Closure $next)
   36     {
   37         $response = $next($request);
   38 
   39         foreach ($this->cookies->getQueuedCookies() as $cookie) {
   40             $response->headers->setCookie($cookie);
   41         }
   42 
   43         return $response;
   44     }
   45 }