This is my code. It is get/set/remove multiple cookies at once. Set and remove (all) works fine but I can't remove just an expired cookie from `CookieCollection`.

```
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Web;
using Newtonsoft.Json;

namespace SetGetMultipleCookies
{
    public partial class GetSetCookiesForm : Form
    {
        string readCookiesUrl = "http://test.dev/_test/cookies/readcookie.php";
        string setCookiesUrl = "http://test.dev/_test/cookies/setcookie.php";
        CookieContainer cookieHeader = new CookieContainer();
        CookieCollection cookie_collection = new CookieCollection();

        public GetSetCookiesForm()
        {
            InitializeComponent();
        }

        private void getCookiesButton_Click(object sender, EventArgs e)
        {
            // begins variable for page content.
            string pageSource;
            // send url request to web page.
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(this.readCookiesUrl);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            foreach (Cookie each_cookie in this.cookie_collection)
            {
                if (!each_cookie.Expired)
                {
                    request.Headers.Add("Cookie", each_cookie.ToString());
                } else
                {
                    // how to remove an expired cookie from cookie collection?

                }
            }

            // read the page content
            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                pageSource = sr.ReadToEnd();
            }

            // display debug.
            resultBox.Text = pageSource + "\r\n";
            foreach (Cookie each_cookie in this.cookie_collection)
            {
                resultBox.Text += each_cookie.ToString() + "; expires=" + each_cookie.Expires + "; path=" + each_cookie.Path + ";domain=" + each_cookie.Domain + "\r\n";
                if (each_cookie.Expired)
                {
                    resultBox.Text += "cookie expired.\r\n";
                }
            }
        }

        private void setCookiesButton_Click(object sender, EventArgs e)
        {
            // send url request to set cookie.
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(this.setCookiesUrl);
            request.Method = "GET";
            request.CookieContainer = this.cookieHeader;
            request.ContentType = "application/x-www-form-urlencoded";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            // set cookies
            this.cookie_collection = response.Cookies;
            // debug
            resultBox.Text = "Headers ==========\r\n";
            foreach (string each_header in response.Headers)
            {
                resultBox.Text += each_header + " = " + response.Headers[each_header] + "\r\n";
            }
            resultBox.Text += "\r\nCookies (" + response.Cookies.Count + ") ==========\r\n";
            foreach (Cookie each_cookie in response.Cookies)
            {
                resultBox.Text += each_cookie.ToString() + "\r\n";
                resultBox.Text += each_cookie.Name + "\r\n";
                resultBox.Text += each_cookie.Value + "\r\n";
                resultBox.Text += each_cookie.Expires + "\r\n";
                resultBox.Text += each_cookie.Path + "\r\n";
                resultBox.Text += each_cookie.Domain + "\r\n";
                resultBox.Text += each_cookie.Secure + "\r\n";
                resultBox.Text += each_cookie.HttpOnly + "\r\n";
                resultBox.Text += each_cookie.Expired + "\r\n";
                resultBox.Text += "\r\n";
            }
            // get response body.
            using (Stream responseStream = response.GetResponseStream())
            {
                StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
                String responseText = reader.ReadToEnd();
                // json decode
                //LoginResponse responsej = JsonConvert.DeserializeObject<LoginResponse>(responseText);
                // display debug.
                resultBox.Text += "Response body ==========\r\n";
                resultBox.Text += responseText + "\r\n";
            }
        }

        private void removeCookiesButton_Click(object sender, EventArgs e)
        {
            this.cookieHeader = new CookieContainer();
            this.cookie_collection = new CookieCollection();

            resultBox.Text = "Logged out.";
        }
    }
}

```

In the `getCookiesButton_Click` method, I just want to remove an expired cookie from `CookieCollection`. How to do that?
How to remove an expired cookie from `CookieCollection`?

[![enter image description here](https://i.stack.imgur.com/9JCsW.png)](https://i.stack.imgur.com/9JCsW.png)

In the red rectangle line, that is the expired cookie first time when click on **Get cookies** it is showing there with expired report which is correct but second time it should be removed completely from the `CookieCollection`.