gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
clear all cookies js
- User
clear all cookies js
- Assistant
To clear all cookies in JavaScript, you can use the following approach. The process involves iterating through all cookies and setting their expiration date to the past, which effectively deletes them. Here's a simple way to do this:
function clearAllCookies() { // Get all cookies in an array const cookies = document.cookie.split(";"); // Loop through the cookies and set each one to expire for (let i = 0; i < cookies.length; i++) { const cookie = cookies[i]; // Get the cookie name and trim any leading whitespaces const cookieName = cookie.split("=")[0].trim(); // Set the cookie to expire document.cookie = cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"; } } // Call the function to clear all cookies clearAllCookies();
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.