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

Simple question about cookies 1
Cookies problem 1
Cookies Count 2
ASP.Net Stored Password Expiring 2
Cookies not persisting accross pages ASP.NET 4
Cookies & Redirection 1
double cookie 2
Login Problem :: 2

Top