Cookies problem (again)

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
 
G

GD

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top