Cookies problem (again)

Discussion in 'ASP .Net' started by The Clansman, May 20, 2004.

  1. The Clansman

    The Clansman Guest

    Hi,
    I tried this in the btnLogin_Click event:

    Response.Cookies("UserEmail").Value = txtEmail.Text
    Response.Cookies("UserEmail").Expires =
    DateTime.Now.AddMonths(1)

    and in the Page_Load event I do this:

    txtEmail.Text = Response.Cookies("UserEmail").Value

    but the return value is still empty, I can read the cookie if I try to read
    as soon I write it:

    Response.Cookies("UserEmail").Value = txtEmail.Text
    Response.Cookies("UserEmail").Expires =
    DateTime.Now.AddMonths(1)
    txtEmail.Text = Response.Cookies("UserEmail").Value

    Thanks,
    Bruno
     
    The Clansman, May 20, 2004
    #1
    1. Advertising

  2. The Clansman

    GD Guest

    Once you have set the cookie value you read it back using the "Request"
    object (not the Response object as in your code sample)

    Assuming you have already written a value to the cookie, use the following
    line to read the value back

    txtEmail.Text = Request.Cookies("UserEmail").Value

    Gary


    "The Clansman" <Yeah! Send me spam!! I love it!! But send the porn ones....>
    wrote in message news:...
    > Hi,
    > I tried this in the btnLogin_Click event:
    >
    > Response.Cookies("UserEmail").Value = txtEmail.Text
    > Response.Cookies("UserEmail").Expires =
    > DateTime.Now.AddMonths(1)
    >
    > and in the Page_Load event I do this:
    >
    > txtEmail.Text = Response.Cookies("UserEmail").Value
    >
    > but the return value is still empty, I can read the cookie if I try to

    read
    > as soon I write it:
    >
    > Response.Cookies("UserEmail").Value = txtEmail.Text
    > Response.Cookies("UserEmail").Expires =
    > DateTime.Now.AddMonths(1)
    > txtEmail.Text = Response.Cookies("UserEmail").Value
    >
    > Thanks,
    > Bruno
    >
    >
     
    GD, May 20, 2004
    #2
    1. Advertising

  3. The Clansman

    The Clansman Guest

    wow!

    I need to get new eyes! :S hehehe

    thanks

    "The Clansman" <Yeah! Send me spam!! I love it!! But send the porn ones....>
    wrote in message news:...
    > Hi,
    > I tried this in the btnLogin_Click event:
    >
    > Response.Cookies("UserEmail").Value = txtEmail.Text
    > Response.Cookies("UserEmail").Expires =
    > DateTime.Now.AddMonths(1)
    >
    > and in the Page_Load event I do this:
    >
    > txtEmail.Text = Response.Cookies("UserEmail").Value
    >
    > but the return value is still empty, I can read the cookie if I try to

    read
    > as soon I write it:
    >
    > Response.Cookies("UserEmail").Value = txtEmail.Text
    > Response.Cookies("UserEmail").Expires =
    > DateTime.Now.AddMonths(1)
    > txtEmail.Text = Response.Cookies("UserEmail").Value
    >
    > Thanks,
    > Bruno
    >
    >
     
    The Clansman, May 20, 2004
    #3
    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. amit
    Replies:
    0
    Views:
    413
  2. che
    Replies:
    2
    Views:
    525
  3. abcd

    Importing again and again

    abcd, Jun 8, 2006, in forum: Python
    Replies:
    9
    Views:
    342
    Maric Michaud
    Jun 9, 2006
  4. _Who
    Replies:
    7
    Views:
    2,774
  5. Ò»Ê×Ê«

    A design problem I met again and again.

    Ò»Ê×Ê«, Apr 1, 2009, in forum: Python
    Replies:
    24
    Views:
    758
    Dennis Lee Bieber
    Apr 4, 2009
Loading...

Share This Page