laravel 之 cookie 使用

<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;
class IndexController extends CommonController
{
	

    public function setCookie(Request $request){
      $minutes = 1;
      $response = new Response('Hello World');
      $response->withCookie(cookie('name', 'virat', $minutes));
      return $response;
   }
   public function getCookie(Request $request){
      $value = $request->cookie('name');
      echo $value;
   }
}

 

posted on 2018-08-15 16:13  小V_chen  阅读(157)  评论(0编辑  收藏  举报

导航