How to set cookie expires date time in asp.net c#

Set cookie expires date time
CookieSetExpires.aspx

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net" %>

<!DOCTYPE html>

<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e) {
        HttpCookie cookie = new HttpCookie("ColorCookie");
        cookie["Color"] = "Crimson";
        cookie["ColorValue"] = "#DC143C";
        cookie.Expires = DateTime.Now.AddYears(1);
        Response.Cookies.Add(cookie);
        Label1.Text = "Cookie created successfully and set expire after 1 year";

        HttpCookie myCookie = Request.Cookies["ColorCookie"];
        if (myCookie != null)
        {
            string color = myCookie["Color"];
            string colorValue = myCookie["ColorValue"];
            Label1.Text += "<br /><br />Cookie[ColorCookie] Found and read<br/>";
            Label1.Text += "Color: " + color;
            Label1.Text += "<br />Value: " + colorValue;
        }
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>asp.net cookie example: how to set expires date time</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Teal">asp.net Cookie example: set cookie expires</h2>
        <asp:Label 
            ID="Label1" 
            runat="server" 
            Font-Size="Large" 
            ForeColor="Crimson"
            Font-Italic="true"
            Font-Bold="true"
            >
        </asp:Label>
    </div>
    </form>
</body>
</html>
More asp.net examples