尊龙凯时人生就是博

laravelÖÐÉèÖÃcookieÓò

ÈôÊÇÄúÕýÔÚʹÓà laravel ¿ò¼Ü¿ª·¢ÍøÕ¾Ó¦ÓóÌÐò£¬Äú¿ÉÄÜÐèÒªÉèÖà cookie ÓòÀ´È·±£ÄúµÄ cookie ÊÊÓÃÓÚÖ¸¶¨µÄÓòÃû¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÌÖÂÛÔõÑùÔÚ laravel ÖÐÉèÖà cookie Óò¡£

ʲôÊÇ Cookie Óò

Cookie ÓòÊÇÖ¸ Cookie ¿ÉÓõÄÓòÃû»ò×ÓÓòÃûÁбí¡£ÀýÈ磬ÈôÊÇÄúÉèÖÃÁËÊÊÓÃÓÚ “.example.com” ÓòµÄ Cookie£¬ÄÇôÕâ¸ö Cookie ¿ÉÒÔÔÚ example.com µÄÈκÎ×ÓÓòÃûÏÂʹÓã¬ÀýÈç blog.example.com ºÍ shop.example.com¡£ÈôÊÇÄúÉèÖÃµÄ Cookie ÓòΪ “example.com”£¬ÔòÕâ¸ö Cookie Ö»ÄÜÔÚ example.com µÄ¸ùÓòÃûÏÂʹÓá£

ÔÚ Laravel ÖÐÉèÖÃ Cookie Óò

ÔÚ Laravel ÖУ¬Äú¿ÉÒÔʹÓà cookie È«¾ÖÖúÊÖºÍ withCookie ÒªÁìÀ´ÉèÖÃÓ¦ÓóÌÐòµÄ Cookie Óò¡£

ÒªÉèÖà Cookie Óò£¬ÇëʹÓà cookie È«¾ÖÖúÊÖÉèÖÃÒ»¸öÐ嵀 Cookie£¬°üÀ¨ÄúҪʹÓõÄÓòÃû£º

$response = response('Hello World')->cookie(
    'name', 'value', $minutes, '/', '.example.com', false, true
);

µÇ¼ºó¸´ÖÆ

´Ë´úÂ뽫ÔÚ “.example.com” ÓòÏÂÉèÖÃÒ»¸öÃûΪ “name” ֵΪ “value”£¬ÓâÆÚʱ¼äΪ $minutes ·ÖÖ Cookie¡£

Äú¿ÉÒÔʹÓà withCookie ÒªÁ콫ÉÏÊö´úÂëÓ¦ÓÃÓÚÓ¦ÓóÌÐòµÄÏìÓ¦ÖУº

return response('Hello World')->withCookie($cookie);

µÇ¼ºó¸´ÖÆ

Çë×¢ÖØ£¬withCookie ÒªÁìÒ²¿ÉÒÔÒ»´ÎÉèÖöà¸ö Cookie£º

return response('Hello World')->withCookie($cookie1, $cookie2, $cookie3);

µÇ¼ºó¸´ÖÆ

ʾÀý

$cookie = cookie('name', 'value', 60);
return response('Hello World')->withCookie($cookie);

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫ÔÚÄ¿½ñÓòÃûÏÂÉèÖÃÒ»¸öÃûΪ “name” ֵΪ “value”£¬ÓâÆÚʱ¼äΪ 60 ·ÖÖ Cookie¡£

ÈôÊÇÄúÏ뽫 Cookie ÓòÏÞÖÆÔÚÄ¿½ñ¸ùÓòÃûÏ£¬Äú¿ÉÒÔʹÓãº

$response = response('Hello World')->cookie(
    'name', 'value', $minutes, '/'
);

µÇ¼ºó¸´ÖÆ

Õ⽫ÔÚÄ¿½ñÓòÃûµÄ¸ùĿ¼ÏÂÉèÖÃÒ»¸ö Cookie¡£

×ܽá

ÔÚ Laravel ÖÐÉèÖà Cookie ÓòÐèÒª½ç˵ҪʹÓõÄÓòÃûºÍ×ÓÓòÃûÁбí¡£Äú¿ÉÒÔʹÓà cookie Óë withCookie ÒªÁìÀ´ÇáËɵØÉèÖÃÓ¦ÓóÌÐòµÄ Cookie£¬²¢ÔÚÐèҪʱÉèÖà Cookie Óò¡£Ï£Íû±¾ÎÄÄܹ»×ÊÖúÄú¸üºÃµÄÖÎÀí Laravel ÖÐµÄ Cookie Óò¡£

ÒÔÉϾÍÊÇlaravelÖÐÉèÖÃcookieÓòµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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