cookie expiry date problem

Discussion in 'ASP .Net Security' started by Ray, Apr 21, 2004.

  1. Ray

    Ray Guest

    Below is the code to save the cookie and set the expiry date of the cooki

    Response.Cookies["demo"].Value ="Hello"
    DateTime dt = DateTime.Now
    TimeSpan ts = new TimeSpan(0,0,10,0)
    Response.Cookies ["demo"].Expires = dt.Add(ts);

    Below is the code to retrieve the stored cookie

    if (!Page.IsPostBack)
    HttpCookie dcookie = Request.Cookies["demo"]
    if (dcookie != null)
    urlevel.Text = dcookie.Values["level"]
    urname.Text = dcookie.Values["user"];
    daysx.Text = Convert.ToString(Request.Cookies["demo"].Expires)

    els
    Response.Redirect ("haha.htm")


    When I display the Response.Cookies ["demo"].Expires = dt.Add(ts); it returns the current date + 10 minute
    But the days.Text returns 01/01/0001. Why? Please help Thanks

    Ray
     
    Ray, Apr 21, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    731
  2. Milsnips
    Replies:
    1
    Views:
    426
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 15, 2007
  3. sheraz_aries

    cookie expiry - classic asp

    sheraz_aries, Mar 20, 2009, in forum: .NET
    Replies:
    0
    Views:
    825
    sheraz_aries
    Mar 20, 2009
  4. Vince C.
    Replies:
    1
    Views:
    211
  5. Guest

    Read cookie expiry date?

    Guest, Aug 7, 2004, in forum: ASP General
    Replies:
    1
    Views:
    224
    Dave Anderson
    Aug 8, 2004
Loading...

Share This Page