前提你的整個http流程一定要走完,頁就是必須走到view()或Response,你寫到中間中斷調試,cookie是設置不上去的......(坑~~)
讀取:
$value = Cookie::get('name');
寫入:
$cookie = Cookie::make('name', 'value', $minutes);//無return 好像有問題 return View::make(xxx)->withCookie($cookie);
刪除:
Cookie::forget('name');
另一種賦值刪除:
Cookie::queue('test', 'testValue', 10); // 10 分鍾
Cookie::queue('test', null , -1); // 銷毀
原生態的cookie操作
setcookie($name, $value , $_t, '/', $domain); setcookie("user", "Alex Porter", time()+3600,'/','test.com');
打印:
var_dump($_COOKIE) ;
刪除:
php中使用“setcookie($cookiename, '');”或者“setcookie($cookiename, NULL);”都會刪除cookie
另一個辦法是設置Cookie的失效時間為 time()或time()-1
