尊龙凯时人生就是搏

laravel5 ɾ³ýcookie

ÔÚ laravel 5 ÖУ¬¿ÉÒÔͨ¹ý $request->cookie() ÒªÁì»ñÈ¡Ä¿½ñÇëÇóÖеÄÖ¸¶¨ cookie Öµ¡£ÈôÊÇÄãÏëɾ³ýÒ»¸öÖ¸¶¨µÄ cookie£¬¿ÉÒÔʹÓà response ʵÀýÉ쵀 withcookie() ÒªÁ죬²¢½« cookie µÄÓâÆÚʱ¼äÉèÖÃΪһ¸öÒÑÍùµÄʱ¼ä¡£ÀýÈ磺

return response('Hello World')->withCookie(cookie('name', null, -1));

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫ÔÚÏìÓ¦ÖÐÉèÖÃÃûΪ name µÄ cookie ֵΪ null£¬²¢½«ÆäÓâÆÚʱ¼äÉèÖÃΪһ¸öÒÑÍùµÄʱ¼ä´Á¡£Í¨¹ýÕâÖÖ·½·¨£¬ä¯ÀÀÆ÷½«²»ÔÙÉúÑĸà cookie£¬´Ó¶øʵÏÖÁËɾ³ý²Ù×÷¡£

ÈôÊÇÄãÏëɾ³ýËùÓÐµÄ cookie£¬¿ÉÒÔÑ­»·±éÀúËùÓÐµÄ cookie£¬²¢»®·ÖÉèÖÃÆäÓâÆÚʱ¼äΪÒÑÍùµÄʱ¼ä¡£

foreach($_COOKIE as $key => $value) {
  setcookie($key, $value, time() - 3600, '/');
}

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂë»áÏȱéÀúËùÓÐµÄ cookie£¬È»ºóʹÓà setcookie() º¯Êý½«Ã¿Ò»¸ö cookie µÄÓâÆÚʱ¼äÉèÖÃΪĿ½ñʱ¼ä¼õȥһСʱ£¬²¢½«Æä·¾¶ÉèÖÃΪ¸ù·¾¶¡£ÈôÊÇÄãÔÚʹÓà Laravel 5£¬¿ÉÒÔʹÓÃËüÌṩµÄ Cookie ¸¨Öúº¯ÊýÀ´ÊµÏÖÏàͬµÄЧ¹û¡£

foreach($_COOKIE as $key => $value) {
  Cookie::queue(Cookie::forget($key));
}

µÇ¼ºó¸´ÖÆ

Cookie::forget() ÒªÁ콫½¨ÉèÒ»¸öÐ嵀 Cookie ʵÀý£¬²¢½«ÆäÓâÆÚʱ¼äÉèÖÃΪÒÑÍùµÄʱ¼ä¡£È»ºó£¬Cookie::queue() ÒªÁ콫¸ÃʵÀýÌí¼Óµ½ÏìÓ¦ÖУ¬´Ó¶øʵÏÖÁËɾ³ý²Ù×÷¡£

ÒÔÉϾÍÊÇlaravel5 ɾ³ýcookieµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ