W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
重定向到新的 URL 的同時(shí) 傳送數(shù)據(jù)給 session 是很常見的。 通常會(huì)在成功執(zhí)行一個(gè)動(dòng)作并傳送消息給 session 之后這樣做。為了方便起見,你可以創(chuàng)建一個(gè) RedirectResponse
實(shí)例并在鏈?zhǔn)椒椒ㄕ{(diào)用中將數(shù)據(jù)傳送給 session :
Route::post('user/profile', function () {
// 更新用戶的信息...
return redirect('dashboard')->with('status', 'Profile updated!');
});
在用戶重定向后,可以顯示 session 中的傳送數(shù)據(jù)。比如使用 Blade syntax :
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: