簡體   English   中英

如果將Cookie設置為同一域中的所有子域,則刪​​除Cookie無效

[英]Delete cookie not working if cookie is set to all subdomains on same domain

我正在創建這樣的cookie:

Cookie::queue(Cookie::make('cookie_name', 'cookie_value', 60, '/', '.domain.com'));

據我了解,cookie被設置為全局域,我的意思是,該cookie也將與子域一起使用。 例如: example.domain.com

但是,如果我要在子域上啟動刪除,則無法刪除它。

Cookie::queue(Cookie::forget('cookie_name'));

我怎樣才能做到這一點?

感謝您的任何答案。

嘗試這個:

Cookie::queue('cookie_name', null, -1);
return Redirect::route('your_route');

您可以使用此代碼刪除Cookie

$cookie = Cookie::forget('cookie_name', null, '.domain.com');
return response()->json(['success' => true, 'message' => 'You are successfully logged out.'])->withCookie($cookie);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM