×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravel post 302¹ýʧ

laravel post 302 ¹ýʧ£º³£¼ûÔµ¹ÊÔ­ÓÉÏ¢Õù¾ö²½·¥

ÔÚʹÓÃLaravel¿ª·¢WebÓ¦ÓóÌÐòʱ£¬Äú¿ÉÄÜ»áÓöµ½Post 302¹ýʧ¡£¸Ã¹ýʧͨ³£ÌåÏÖÇëÇóÒÑÀֳɴ¦Àí£¬µ«ÐèÒª½øÒ»²½²Ù×÷²Å»ªÍê³É¸ÃÇëÇó¡£Í¨³££¬Äú»á¿´µ½Öض¨ÏòµÄÁ´½Ó×÷ΪÏìÓ¦¡£ÕâƪÎÄÕ½«ÏÈÈÝһЩ³£¼ûµÄÔµ¹ÊÔ­ÓÉÏ¢Õù¾ö²½·¥£¬ÒÔ×ÊÖúÄú½â¾öLaravel Post 302¹ýʧ¡£

CSRF ÁîÅÆÑé֤ʧ°Ü

Ò»¸ö³£¼ûµÄÔµ¹ÊÔ­ÓÉÊÇÔÚPostÇëÇóÖÐÑéÖ¤CSRFÁîÅÆʧ°Ü¡£Laravel»á×Ô¶¯ÔÚÿ¸ö±íµ¥ÖаüÀ¨CSRFÁîÅÆ£¬ÒÔÈ·±£ÇëÇóÀ´×ÔÓÚÓ¦ÓóÌÐòµÄÕýµ±ÈªÔ´¡£ÈôÊÇCSRFÁîÅÆÑé֤ʧ°Ü£¬ÔòÇëÇ󽫱»Öض¨Ïòµ½³õʼÇëÇóÒ³Ãæ»òµ½Ä¬ÈÏÖ÷Ò³£¬²¢ÏÔʾ302¹ýʧ¡£

½â¾ö²½·¥£ºÈ·±£ÔÚÿ¸öÐèÒª±£»¤µÄ±íµ¥ÖаüÀ¨CSRFÁîÅÆ¡£ÈôÊÇÁîÅÆÓâÆÚ£¬¿ÉÒÔʹÓÃÒÔÏ´úÂëÔÚ±íµ¥ÖÐÖØÐÂÌìÉúеÄÁîÅÆ£º

{{ csrf_field() }}

µÇ¼ºó¸´ÖÆ

»á»°ÓâÆÚ

ÁíÒ»¸ö³£¼ûµÄÔµ¹ÊÔ­ÓÉÊǻỰÓâÆÚ¡£Ä¬ÈÏÇéÐÎÏ£¬Laravel»á»°ÔÚ2СʱºóÓâÆÚ¡£ÈôÊÇÄú³¤Ê±¼äδִÐÐÈκβÙ×÷£¬»á»°½«ÓâÆÚ£¬ÄúµÄPostÇëÇ󽫱»Öض¨Ïòµ½µÇ¼ҳÃ棬¶ø·ºÆð302¹ýʧ¡£

½â¾ö²½·¥£º¿ÉÒÔͨ¹ýÒÔÏÂÁ½ÖÖ·½·¨ÑÓÉìLaravel»á»°µÄÓÐÓÃÆÚ£º

-ÔÚconfig/session.phpÎļþÖÐÐ޸Ēdriver’ => ‘file’ Ϊ ‘driver’ => ‘cookie’£¬Õ⽫ʹÓÿͻ§¶Ëcookie´æ´¢»á»°ÐÅÏ¢£¬¶ø²»ÊÇ´æ´¢ÔÚЧÀÍÆ÷ÉϵÄÎļþ¡£

-ÔÚconfig/session.phpÎļþÖн«lifetime²ÎÊýÉèÖÃΪËùÐèµÄСʱÊý£¬ÈçÒÔÏ´úÂëËùʾ£º

'lifetime' => 24 * 60 // 1Ìì

µÇ¼ºó¸´ÖÆ

RedirectÏìÓ¦

ÔÚijЩÇéÐÎÏ£¬PostÇëÇó¾­ÓÉ´¦Àíºó»á·µ»ØÒ»¸öÖض¨ÏòÁ´½Ó£¬¶ø²»ÊÇÖ±½Ó·ºÆðЧ¹û¡£ÕâÒâζ×ÅÇëÇóÒÑÀÖ³ÉÍê³É£¬µ«ÐèÒª½øÒ»²½²Ù×÷²Å»ªÍê³É¡£

½â¾ö²½·¥£º¼ì²éÄúµÄPostÇëÇó´¦ÀíÆ÷£¬È·±£Ëü·µ»Ø׼ȷµÄÏìÓ¦¡£ÈôÊÇÐèÒªÖض¨Ïò£¬ÇëÈ·±£ÄúÕýÔÚʹÓÃ׼ȷµÄURL¡£Äú¿ÉÒÔʹÓÃLaravelµÄredirectÒªÁìÀ´ÌìÉú׼ȷµÄÖض¨ÏòURL£¬ÈçÒÔÏ´úÂëËùʾ£º

return redirect('dashboard')->with('success', 'Post created successfully');

µÇ¼ºó¸´ÖÆ

³ÌÐòÄÚ²¿¹ýʧ

ͨ¹ýÒÔÉϽâ¾ö²½·¥ºóÈÔÈ»ÓÐ302¹ýʧ£¬Ôò¿ÉÄܱ£´æ³ÌÐòÄÚ²¿¹ýʧ¡£×î³£¼ûµÄ¹ýʧÊÇÓï·¨¹ýʧºÍÂß¼­¹ýʧ¡£ÕâЩ¹ýʧ»áµ¼ÖÂÇëÇóδÄÜÀֳɴ¦Àí£¬»òÕß·µ»ØÁ˲»×¼È·µÄÖض¨ÏòÁ´½Ó£¬´Ó¶øµ¼ÖÂ302¹ýʧ¡£

½â¾ö²½·¥£ºÔÚ´úÂëÖÐÌí¼Óµ÷ÊÔÓï¾ä£¬ÒÔ²éÕÒ¹ýʧ±¬·¢µÄλÖò¢ÐÞ¸´ËüÃÇ¡£Ê¹ÓÃLaravelµÄÈÕÖ¾¼Í¼¹¦Ð§£¬¿ÉÒÔÇáËɵؼͼ¹ýʧÐÅÏ¢²¢¾ÙÐе÷ÊÔ¡£»¹¿ÉÒÔʹÓõ÷ÊÔÆ÷À´ÊµÊ±Éó²é´úÂëÖеıäÁ¿ÖµºÍÖ´ÐÐÀú³Ì¡£

×ܽá

Laravel Post 302¹ýʧͨ³£ÌåÏÖÇëÇóÒÑÀֳɴ¦Àí£¬µ«ÐèÒª½øÒ»²½²Ù×÷²Å»ªÍê³É¡£³£¼ûµÄÔµ¹ÊÔ­ÓÉ°üÀ¨CSRFÁîÅÆÑé֤ʧ°Ü¡¢»á»°ÓâÆÚ¡¢RedirectÏìÓ¦ºÍ³ÌÐòÄÚ²¿¹ýʧ¡£Í¨¹ý¼ì²éÕâЩԵ¹ÊÔ­Óɲ¢½ÓÄÉÊʵ±µÄ½â¾ö²½·¥£¬¿ÉÒÔÇáËɵؽâ¾öLaravel Post 302¹ýʧ£¬²¢Ìá¸ßWebÓ¦ÓóÌÐòµÄÎȹÌÐÔºÍÇå¾²ÐÔ¡£

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

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ