DataTime dt=DateTime Now;
TimeSpan ts=new TimeSpan(365,0,0,0);
HttpCookie yourCookie=new HttpCookie("user");
...
yourCookie.Expires=dt.ts;
我想一年你够了吧!要不你再加?

解决方案 »

  1.   

    yourCookie.Expires = DateTime.MinValue;
    hehe,谢谢大家了,这个最标准的答案。
      

  2.   

    Faint!应该是:yourCookie.Expires = DateTime.MaxValue;
    经过测试以后。
    tmd!是MS新闻组里的一个MVP告诉我yourCookie.Expires = DateTime.MinValue的。
      

  3.   

    老大,我看了VS.net的联机帮助,这个:
    MaxValue方法也是有时间限制的!!时间不太长,50年!!!哈哈哈~~
      

  4.   

    TomMax(笑望人生) :你从哪里看到的是50年?下面为SDK内容:
    ----------------------------------------------------------
    表示 DateTime 可能的最大值。此字段为只读。[Visual Basic]
    Public Shared ReadOnly MaxValue As DateTime
    [C#]
    public static readonly DateTime MaxValue;
    [C++]
    public: static DateTime MaxValue;
    [JScript]
    public static var MaxValue : DateTime;
    备注
    此常数的值等效于 9999 年 12 月 31 日 23:59:59.9999999,恰好在 10000 年 1 月 1 日 00:00:00 之前一个 100 毫微秒刻度处。