Cookies problem (again)

  • Thread starter Thread starter The Clansman
  • Start date Start date
T

The Clansman

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
 
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
 
Back
Top