laravel에서 쿠키 사용 설명

4061 단어 Laravel
	Laravel         cookie  ,       ,        cookie   , cookie    ,       。
1.Cookie::make()       cookie 、Cookie::forever()          cookie  、Cookie::get()        cookie 
 
  
Route::get('cookieset', function()
{
    $foreverCookie = Cookie::forever('forever', 'Success');
    $tempCookie = Cookie::make('temporary', 'Victory', 5);
    return Response::make()->withCookie($foreverCookie)->withCookie($tempCookie);
});


Route::get('cookietest', function()
{
     $forever = Cookie::get('forever');
     $temporary = Cookie::get('temporary');
     return View::make('cookietest', array('forever' => $forever, 'temporary' => $temporary, 'variableTest' => 'works'));
});

참고:
laravel5.2  make    
        
Cookie::queue('GobackUrl', $url, 30);
    ,       Cookie      ,       JS   ,JS          ,           :
    #
	  cookie    cookie_for_js        
 	    App\Http\Middleware\EncryptCookies         :

참, JS에 읽으려면 쿠키를http only
등록 정보를 제거하려면 다음 코드를 사용하십시오.
Cookie::queue('cookie_for_js', 'can you read me?', $minutes = 99999999, $path = null, $domain = null, $secure = false, $httpOnly = false);
2、Cookie    :
Route::get('cookieset', function()
{
    $user_info = array('name'=>'good','age'=>12);
    $user = Cookie::make('user',$user_info,30);
    return Response::make()->withCookie($user);
});

Route::get('cookietest', function()
{
    dd(Cookie::get('user'));
});

좋은 웹페이지 즐겨찾기