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. Advertisements

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. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,788
    Michael Borgwardt
    May 30, 2004
  2. Replies:
    0
    Views:
    822
  3. Milsnips
    Replies:
    1
    Views:
    503
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 15, 2007
  4. sheraz_aries

    cookie expiry - classic asp

    sheraz_aries, Mar 20, 2009, in forum: .NET
    Replies:
    0
    Views:
    933
    sheraz_aries
    Mar 20, 2009
  5. Vince C.
    Replies:
    1
    Views:
    303
  6. Guest

    Read cookie expiry date?

    Guest, Aug 7, 2004, in forum: ASP General
    Replies:
    1
    Views:
    307
    Dave Anderson
    Aug 8, 2004
  7. Replies:
    1
    Views:
    339
    Michael Faires-McClellan
    Sep 27, 2005
  8. Hardeep Rakhra

    Help With Cookie Expiry

    Hardeep Rakhra, Jan 15, 2004, in forum: Javascript
    Replies:
    1
    Views:
    174
    Hardeep Rakhra
    Jan 15, 2004
Loading...